Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An imperative block without a return statement returns null #2

Open
pboyer opened this issue May 31, 2016 · 2 comments
Open

An imperative block without a return statement returns null #2

pboyer opened this issue May 31, 2016 · 2 comments

Comments

@pboyer
Copy link
Contributor

pboyer commented May 31, 2016

No description provided.

@pboyer pboyer added the TODO label May 31, 2016
@lukechurch
Copy link
Contributor

(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
Copy link
Contributor Author

pboyer commented Jun 1, 2016

That sounds very reasonable. Thanks @lukechurch!

@pboyer 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 pboyer removed the TODO label Oct 27, 2016
@pboyer pboyer closed this as completed Oct 31, 2016
@pboyer pboyer reopened this Oct 31, 2016
@pboyer 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants