-
Notifications
You must be signed in to change notification settings - Fork 11
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
Imperative block syntax, function definition syntax #11
Comments
I'd suggest that function doesn't have return type, or always be |
@pboyer I think considering applying [Imperative] to other things than 'bare blocks' is a good idea. Where it's reasonable, it's really just an annotation on the structure that adjusts the semantics. I'm very cautious about the UX impact of inference. It makes code terse to write, but difficult to read and can cause unexpected behaviour changes. What happens if the first statement of a function isn't imperative? Do you switch the whole function to imperative because of a single statement? In general in user studies elsewhere we've seen that inference only works well when it's very local, predictable and has good tool support to help the user reason about what is going on. I like the direction the anonymous functions are going in, but find the examples a little hard to read above and I'm not overly keen on introducing the word lambda :) I think the () are getting over-used for too many different things as a syntactic construct. |
@ke-yu Functions having return types is UX helpful - it helps people know what they're going to get back from the function. If the function type is an annotation only and gets ignored at runtime, now you potentially a function that says one thing and actually does another. That seems like it leads to confusions. |
BTW @pboyer Do feel free to assign things like this to me if you're asking me a question - or drop me a note. I didn't reply for such a long time because the notification got lost in the noise of my inbox. Sorry about that. |
@lukechurch I just put your name on it if you had any thoughts. Task assignment seems so formal... The syntax for |
@pboyer lambda could be more general
|
could be compiled to
|
There is a case to be made for
[Imperative]
attributes for function definitions, e.g.:This could also clearly be inferred.
This is an assigned imperative block, with proposed dependency capture vars:
An assigned imperative block is thus a lot like an immediately evaluated anonymous function, in proposed syntax:
However, this form actually is more powerful, as the type declaration allows for replication to be performed:
IOW, the user can specify whether the the captured variables should be interpreted as a compound or singular value.
Perhaps, we can modify the
Imperative
block capture list to include a type annotation:@lukechurch
The text was updated successfully, but these errors were encountered: