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

promote exception throwing to expression #756

Open
jurgenvinju opened this issue Jan 15, 2015 · 4 comments
Open

promote exception throwing to expression #756

jurgenvinju opened this issue Jan 15, 2015 · 4 comments

Comments

@jurgenvinju
Copy link
Member

Having to write this is awkward:

data MyGraph(MyLayoutStrategy strategy = MyLayoutStrategy () { throw "no default value"; }());

if we promote the throw statement to expression level:

data MyGraph(MyLayoutStrategy strategy = throw "no default value"); 
@DavyLandman
Copy link
Member

👍

Can we als do this for other result generating statements? Such as a for?

@DavyLandman
Copy link
Member

Ow wait, I thought this was about the shorthand for functions that return one statement..

@mahills
Copy link
Member

mahills commented Jan 15, 2015

Instead of making throw an expression, maybe it would make more sense to allow statements on the right-hand side of variable and keyword declarations? This is already allowed for assignables, so this would just make the two more consistent, which seems like a smaller change (given all the assignments currently are of the form <Expression e>;, this also wouldn't require changing any existing code). This would mean that there would be more cases where something is given on the right that doesn't make sense, but, again, we already handle this for assignables.

@jurgenvinju
Copy link
Member Author

@mahills that would also be a good solution, and for single expression function declarations as well. While we haven't integrated expressions and statements yet, it seems like the best thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants