You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(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.
pboyer
changed the title
What happens when an imperative block lacks a return? Return last expr?
What happens when an imperative block lacks a return?
Jun 1, 2016
pboyer
changed the title
What happens when an imperative block lacks a return?
An imperative block without a return statement returns null
Oct 31, 2016
No description provided.
The text was updated successfully, but these errors were encountered: