Expressions everywhere plus optional parallel assignments

The more I work on Skila the more I appreciate features with uniform behaviour. Lately I tried to add basic tail call optimization for current function — nothing more is required than reassigning the arguments and jumping to the top of the function.

But since I use PHP as backend which has very strict distinction between expressions and statements I failed — function call is an expression and jump (goto) is a statement. This was enough to motivate me to rewrite language part of Skila to make all statements, control structures expressions. They don’t produce any values yet, it will take more effort than just changing grammar.

The second solid change is support for optional parallel assignments (and declarations). You could of course write such code by hand:

if year ?= (y_str to ?Int) 
   and month ?= (m_str to ?Int) then

But consider what will happen when month conversion fails — year part will be altered. Maybe it is intended, maybe not — for the latter case Skila provides transaction-like assignment:

if (year,month) ?= (y_str to ?Int , m_str to ?Int) then

The variables will be updated only if both conversions succeed.

Tagged , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: