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

Add anonymous functions/lambdas #671

Open
Goju-Ryu opened this issue Dec 27, 2024 · 0 comments
Open

Add anonymous functions/lambdas #671

Goju-Ryu opened this issue Dec 27, 2024 · 0 comments

Comments

@Goju-Ryu
Copy link
Contributor

Goju-Ryu commented Dec 27, 2024

Following discussion in #261, it was decided to move discussion about lambdas to a separate issue. There are a few unknowns still in regards to the implementation and syntax. The syntax is mostly a preference issue with many proposed syntax's.
Here are most or all of the discussed variations:

(a, b) => a + b

|a, b| = a + b 
|a, b| => a + b

\(a, b) = a + b
\(a, b) => a + b

fn (a, b) = a + b
fn (a, b) a + b

The implementation aspect relates to closures and their handling which is not as straightforward a problem to solve. See #347 for more on this.

Other questions about the implementation were discussed in this comment but is copied below with the syntax updated to current numbat syntax for ease of access.

  • Do we want partial function application "by default"? Or would users have to curry/uncurry manually, i.e. write scale as fn scale(a) = |x| a * x and then use it with expr -> scale(10).

  • Do we need anonymous functions if we have closures and lambdas?

  • Do we want to keep both expr |> fn and expr -> fn? Right now, they are not 100% equivalent, expr |> fn can only be used for "proper" functions, while expr -> fn can also be used for other callables (function pointers), like in now() -> tz("Europe/Berlin")

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

2 participants