HaxeFoundation / HaxeFoundation/as3hx
problem with lack of block-level scope variables in as3
- Dominant language
- Haxe
- Stars
- 180
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
Problem that haxe variables are block-level scoped, but as3 ones are not.
From ActionScript3 documetation:
> ActionScript variables, unlike variables in C++ and Java, do not have block-level scope. A block of code is any group of statements between an opening curly brace ( { ) and a closing curly brace ( } ). In some programming languages, such as C++ and Java, variables declared inside a block of code are not available outside that block of code. This restriction of scope is called block-level scope, and does not exist in ActionScript. If you declare a variable inside a block of code, that variable will be available not only in that block of code, but also in any other parts of the function to which the code block belongs. For example, the following function contains variables that are defined in various block scopes. All the variables are available throughout the function.
```
function blockTest (testArray:Array)
{
var numElements:int = testArray.length;
if (numElements > 0)
{
var elemStr:String = "Element #";
for (var i:int = 0; i < numElements; i++)
{
var valueStr:String = i + ": " + testArray[i];
trace(elemStr + valueStr);
}
trace(elemStr, valueStr, i); // all still defined
}
trace(elemStr, valueStr, i); // all defined if numElements > 0
}
blockTest(["Earth", "Moon", "Sun"]);
```
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry point. Reproduce the supplied blockTest example through the converter and inspect the generated Haxe scope behavior; done means the converted result preserves ActionScript's function-level availability for variables declared inside blocks.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100