Colin Moock on AS4/ECMAScript 4.0 at FITC

The standards talked about are not slated to be implemented until at least december 2008.

You can see Colin’s notes from his presentation at the following address:

Here is a summary of what he covered in his talk, this is all covered in the link above but I thought that I would just post the items that interested me the most:

Structure Types
– record type
easier way to create custom object types, instead of using classes
– array type
ability to apply types to elements within arrays
– union types
gives the option of assigning one of several datatypes to a variable
ie: var x:(int|string) // x must be either an int or a string

Type changes:
It looks like byte, uint, int are being removed from ECMAScript but they will most likely stay in AS for the time being.
There are a series of new lower case types including string, number, and boolean
There are going to be non-nullable types that cannot be assigned the value of null, the idea is to save time in type catching.

Lexical block scoping lets you create variables without var, it allows you to create assign values to variables within code blocks. Check the lecture for an example, it looks like it would be useful if you have a temporary variable.

You will have the power to create single line functions in the same way that you can currently create a single like conditional statement.

!!= can be used to shorten variable assignment, can turn myVar = myVar || “default” to myVar !!= “default”

Type casting can be done using the operator “cast” ie: food cast Apple

Switch type can be used to test the type of variable in a switch statement to allow for multiple types and custom functionality for each

String indexing looks like it may be a little useful, you can access characters in a string the same way that you would access items in an array “test”[2] would produce “s”. Similarly you can use slice on a string to get a range of characters quickly.

Thats all for now.

Leave a Reply

Your email address will not be published. Required fields are marked *