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

consider using fn(a, b) for lambdas? #934

Open
jyn514 opened this issue Nov 22, 2024 · 0 comments
Open

consider using fn(a, b) for lambdas? #934

jyn514 opened this issue Nov 22, 2024 · 0 comments

Comments

@jyn514
Copy link

jyn514 commented Nov 22, 2024

first off i want to say this is a really cool project :D i’ve wanted a language like this ever since i read withoutboats’ post about “notes on a smaller rust”.

one thing that’s always bothered me in rust is how the closure syntax is hard to parse for both humans and compilers. i think something closer to javascript would be easier to read and have a more direct analogy to named function definitions for people who don’t come from a rust or ruby background.

let double = fn(x) x*2;
let divmod = fn(dividend, divisor) {
  (dividend/divisor, dividend%divisor)
};

something i also wish rust had is a way to let named functions still capture state from their environment; reusing the fn syntax gives you a natural way to do things like adding generics to a closure while still having a capturing/non-capturing distinction.

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

1 participant