These days I got some spare time to work on the 2nd preview release of ABS, with loads of interesting features making into this version.
Let me quickly run you through the most notable additions:
Array destructuring
Similar to JS’ destructuring, you can now assign multiple variables based on the elements of an array:
1 2 3 4 |
|
The line before a destructuring statement needs to end
with a ;
, but we’ll fix the parser:
1 2 3 4 5 6 7 8 |
|
Standard input
My personal favorite, you can now capture stdin
with the
(surprise) stdin()
function. An asciicast is better than
words:
Note that you can loop through the stdin
as well:
1 2 3 |
|
Floats
Weird that I didn’t look into this earlier :)
Floats are now fully supported, and integers have been replaced with the generic “number”, wich represents both integers and floats:
1 2 3 4 |
|
You can also “convert” a float to integer using int()
:
1
|
|
Compound assignments & additional operators
These aren’t crazy, but weren’t there in the first preview of ABS:
1 2 3 4 5 6 7 8 9 10 |
|
Nothing much to explain here, I’m sure you’re familiar with these.
Note that I opted to keep ++
and --
out of the picture for now
as the complexity of implementing those is, in my opinion, not worth
it since you can simply x+=1
.
What now?
Grab the latest release for your platform, dump it in your path and start hacking with ABS!
If you’re brave enough, just:
1
|
|
(you might need to sudo right before that)
Cheers!