I’ve recently been working on Slang, my scripting language for Flash, and yesterday I accidentally rewrote the entire thing. I started out refactoring of the parser, and ended up completely redesigning the way the language is executed.
The biggest internal change is that source must now be compiled before execution. This allows for a performance boost when running scripts multiple times, as the bytecode can be cached. Compiling is still quite fast, though, so it’s just as easy to use Slang in a dynamic way, such as an in-game console.
Another feature in this version is the introduction of Scopes. A Scope is a simple data structure which contains statements and can be executed by the application. Currently, they are used for conditional statements.
if condition { print "true!" } ifelse condition { print "true!" } { print "false!" }
In the future, they will also allow closures and script functions.
With the addition of Scopes, the use of semicolons as artificial separators is no longer necessary, and they have therefore been removed from the language keyword set.
With this release I’ve moved Slang out of FLAKit and into its own repository. You can follow it here.
[…] I use Flash, I’ve started using Ogmo Editor to design my levels, XML to handle settings, and Slang to handle game logic whenever possible. As a result, a lot of the code I’ve written recently […]
[…] done some parser work before (notably for Slang), so the markup interpreter was fairly straightforward. All formatting is done with […]
[…] on the engine I wrote for Hypothermia. I created a data-driven cutscene scripting system using Slang, which I wrote about here. This was immensely helpful both in terms of writing reusable code and […]
[…] the base code you’ve gotten used to using. When I was using Actionscript 3 regularly, I wrote Slang to meet the lack of a scripting language that ran inside of Flash and ended up using it for a number […]