Skip to content

Releases: abs-lang/abs

v2.6.0

15 Apr 09:51
Compare
Choose a tag to compare

A fresh new minor release of ABS: always be shipping! 🚢

This is a small one, but we wanted to get defer out of the way, after lying in our 2.6.x branch for months.

Ability to defer functions

Sometimes it is very helpful to guarantee a certain function is executed
regardless of what code path we take: you can use the defer keyword for
this.

echo(1)
defer echo(3)
echo(2)

When you schedule a function to be deferred, it will be executed right at
the end of the current scope. A defer inside a function will then
execute at the end of that function itself:

echo(1)
f fn() {
    defer echo(3)
    echo(2)
}
fn()
echo(4)

You can defer any callable: a function call, a method or even a system
command. This can be very helpful if you need to run a cleanup function
right before wrapping up with your code:

defer `rm my-file.txt`
"some text" > "my-file.txt"

...
...
"some other text" >> "my-file.txt"

In this case, you will be guaranteed to execute the command that removes
my-file.txt before the program closes.

Be aware that code that is deferred does not have access to the return value
of its scope, and will supress errors -- if a defer block messes up you're
not going to see any error. This behavior is experimental, but we would most
likely like to give this kind of control through try...catch...finally.

What else has changed?

Full Changelog: 2.5.2...2.6.0

v2.5.2

14 Apr 09:25
Compare
Choose a tag to compare

A fresh new patch release of ABS: always be shipping! 🚢

Upgrade to Go 1.18

Go 1.18 was released last month and ABS gets updated quickly 🙂

There are no major changes in the platform, but sometimes it's all about housekeeping! 🧹 ☁️

v2.5.1

01 Sep 13:05
Compare
Choose a tag to compare

A fresh new patch release of ABS: always be shipping! 🚢

Upgrade to Go 1.17

Go 1.17 was released last month and ABS gets updated quickly 🙂

There are no major changes in the platform, but sometimes it's all about housekeeping! 🧹 ☁️

v2.5.0

12 May 18:15
Compare
Choose a tag to compare

A fresh new minor release of ABS: always be shipping! 🚢

Added a negative membership operator !in

Earlier, you could test membership with x in list, but in order to negate that expression you had to !(x in list) which is quite verbose.
We now added in #412 the !in operator to make things simpler: x !in list, it behaves just like python's not in.

Module cache

Every time you required a module, you'd always get a fresh instance of it, which would cause some funny behaviors:

$ require('@runtime').name = "xxx"
$ require('@runtime').name
abs

We now (#428) cache modules as soon as they are required, so the next time you require them you will receive the same instance you've required before:

$ require('@runtime').name = "xxx"
$ require('@runtime').name
xxx

This only applies to require and not source, as source is intended to be used in order to always evaluate a block of fresh code in the current environment.

Specify your own shell

In #429 we added the ability to execute commands with any shell, not just bash -c.

You can now specify a different shell to execute system commands with through ABS_COMMAND_EXECUTOR:

`echo \$0` # bash
env("ABS_COMMAND_EXECUTOR", "sh -c")
`echo \$0` # sh

v2.4.2

30 Mar 16:09
Compare
Choose a tag to compare

A fresh new patch release of ABS: always be shipping! 🚢

Fixed parsing of numbers and their sign

By solving #409, we bring a little more stability and less funkiness in ABS' parser.

The way ABS used to parse prefixes (eg. -5) was kind of wonky:
we would dump in a token the whole prefix + number (-5) vs
parsing them separately and build the AST according to where
the minus token is found. This change makes it so -5 is actually
(-)(5).

Problems with the previous approach:

  • inconsistent behavior between x = 5; -x and -5
  • -5 would be treated differently than - 5
  • code such as 1 -1 would be parsed as (1); (-1), producing 2
    statements. The return value would be -1 rather than 0

In general, I looked around and the common behavior is to read
tokens separately and, while parsing, figure out, based on their
position, what precedence they should have. This is what this PR
fundamentally does.

For example:

  • when - is a prefix (-2), it should have the highest precedence over
    any other operator. For example, -2.clamp(0, 1) should interpret as
    (-2).clamp(0, 1)
  • when - is not a prefix, it can fallback to its usual precedence (eg.
    less than * or /)

Thie behavior is also consistent with other, languages, take ruby as an
example:

irb(main):011:0> -1.clamp(0, 10)
=> 0

One way in which ABS now deviates with other implementations
is that, since we do not bother reading whitespaces etc in our lexer
-1.clamp(0, 10) and - 1.clamp(0, 10) are exactly the same (while
in ruby, for example, the latter is intepreted as (-)(1.clamp(0, 10))). I think for now this is a reasonable compromise, but I'm open
to change this behavior in subsequent versions of ABS.

This PR also fixes a couple additional issues:

  • +2 is now a valid number, earlier we only considered - as the only
    valid prefix for numbers
  • there could be instances where an infinite loop would be triggered
    because of ABS parsing x +y as x; +y; where the return value is just
    +y. A for loop written like this would have triggered the bug: decr = f(x) {x -1}; for x = 0; x > -10; x = decr(x). It would only happen on for loops where our looper is decrementing

v2.4.1

17 Feb 08:29
Compare
Choose a tag to compare

A fresh new patch release of ABS: always be shipping! 🚢

Upgrade to Go 1.16

Go 1.16 was released yesterday and ABS gets updated quickly 🙂

There are no major changes in the platform, but sometimes it's all about housekeeping! 🧹 ☁️

v2.4.0

28 Sep 09:34
Compare
Choose a tag to compare

A fresh new minor release of ABS: always be shipping! 🚢

array.shuffle()

We've introduced a new array.shuffle() function:

⧐  [1,2,3,4,5].shuffle()
[4, 5, 3, 2, 1]

array.reverse() operates on a copy of an array

We're in the process of making sure that functions that mutate arrays always operate on a copy of the array. This is somewhat of a breaking change but it also introduces an "expected" behavior (we align with Ruby here). You can expect other updates, in ABS 1.5, to align other array / string functions to this behavior.

Prior to this change:

a = [1,2,3,4,5]
⧐  a.reverse()
[5, 4, 3, 2, 1]
⧐  a
[5, 4, 3, 2, 1]

After this change:

a = [1,2,3,4,5]
⧐  a.reverse()
[5, 4, 3, 2, 1]
⧐  a
[1, 2, 3, 4, 5]

If you have older code that relies on mutating arrays in-place, you could migrate from x.reverse() to x = x.reverse().

v2.3.1

25 Aug 16:38
Compare
Choose a tag to compare

A fresh bugfix for ABS!

#402 fixes a nasty bug with silent returns (return statements without a value, which default to NULL).

The PR fixes them and adds some more sophisticated tests. A return without a value, when interpreted before this PR, would terminate the script without executing the rest of the code.

This snippet:

if false {
	return
}
return 3

would return NULL instead of 3.

v2.3.0

14 Aug 16:34
Compare
Choose a tag to compare

A fresh new minor release of ABS: always be shipping! 🚢

ABS allows you to check whether you should upgrade 😄

When you run the REPL with abs, it will periodically print whether there's a new release you should upgrade to (#392):

$ abs
Hello user, welcome to the ABS (2.2.2) programming language!
*** Update available: 2.3.0 (your version is 2.2.2) ***
Type 'quit' when you're done, 'help' if you get lost!
⧐  

A new command has also been added if you want to explicitly check for a new version:

$ abs --check-update 
Update available: 2.3.0 (your version is 2.2.2)

Upgrade to Go 1.15

ABS is now built with Go 1.15 (#397). As a result, we dropped support for darwin/386 (#396).

The REPL used to suppress output when ending with a comment

A fairly annoying behavior (#388) we fixed by discarding comments right at the lexer's level (#394).

A big thank you to @gromgit who's the main contributor behind this release -- see ya! 👋

v2.2.2

28 Jul 14:38
Compare
Choose a tag to compare

This release fixes a bug with parsing negative numbers (#385): before, -10 would be parsed as (minus, number) whereas
right now it's going to be parsed as (number) only.

This fixes a bug with precedences, where -1.str() would be parsed as (-, (1, str)), leading to first calling the str method on the positive number, then applying the minus.

Before:

⧐  -1.234.str()
ERROR: unknown operator: -STRING
	[1:1]	-1.234.str()

After:

⧐  -1.234.str()
-1.234

If a space is found between the minus and the number, the old parsing mechanism still applies.

It's inspired by Ruby, where:

$ - 1.to_s()
-@: undefined method `-@' for "1":String

$-1.to_s()
-1

$ -10.3.floor()
-11

$ - 10.3.floor()
-10

In addition, the documentation for strings has been improved (#384).

Thanks to @gromgit both for finding the bug as well as improving the documentation ❤️