-
Notifications
You must be signed in to change notification settings - Fork 50
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
Lambda support #82
Comments
Yeah. Internally I decided to call the feature I added a bunch of tests to Personally I kind of like the fat arrow
I'd like to further expand the
|
What is the reason for a separate lambda syntax, why not just have anonymous nested methods? This is the route taken by Go, it's more general and there's one less concept e.g. https://gobyexample.com/closures |
Actually I think what I am proposing is really close to what Go does. The fat arrow E.g. a method:
And a function expression:
Have a look at some of the examples in |
Much clearer, thanks. The test examples are all single-statement anonymous functions. Are multi-statement anonymous functions allowed? For example is this closure over a multi-statement anonymous function valid?
|
Yes, that would be valid (in terms of syntax[1]), though I think I want to disallow closing over mutable locals and only allow closing over [1] with a minor correction in the return type:
Java also doesn't allow closing over mutable locals. So you could, e.g. use an array.
|
as long as they allow closing over something in outer scopes, Virgil would be able to idiomatically express Knuth's so-called "Man or Boy test" as depicted here for other programming languages - https://rosettacode.org/wiki/Man_or_boy_test (idiomatically, as opposed to simulating such lambda-closures with classes) |
Yes, the idea is that you can indeed close over immutable variables in function scopes. |
virgil/doc/tutorial/Functions.md
Line 174 in 3709c05
I guess this means anonymous functions with closures?
For example:
The text was updated successfully, but these errors were encountered: