DynamoDS / DesignScript

About the DesignScript language
Apache License 2.0
11 stars 10 forks source link

An imperative block without a return statement returns null #2

Open pboyer opened 8 years ago

lukechurch commented 8 years ago

(Let me know if me answering these ever gets unhelpful)

The design was that it should return null.

Whilst this is a little bit annoying and slightly harms exploration, it does mean that it's less fragile to changes in the ordering of the code and makes it slightly more predictable.

It's tangled to a broader issue that I now consider a mistake that DesignScript has statements at all rather than everything being an expression. Consequently if we had it return the last expression there'd be all sorts of ugly things to deal with:

r = [Imperative]  {
a = 2;
if (false) { print ("Woof"); } else { print "Meow"; )
}

Which is the 'last expression'? I think valid arguments could be made for '2', 'false' and "Meow". "Last assigned variable" might be a workable alternative, and then you only have to decide what happens with scoping etc.

This all got far too messy, so we went with null.

pboyer commented 8 years ago

That sounds very reasonable. Thanks @lukechurch!