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

let function syntax #569

Closed
wants to merge 2 commits into from
Closed

Conversation

francois-caddet
Copy link
Contributor

@francois-caddet francois-caddet commented Jan 12, 2022

Extend the language to accept ML like functions declaration:

let f a b = a + b in f 3 5

discuced in #207
Can accept patterns params like in #81 but with this new syntax. Only the first element after the let has to be an identifier, because it's the name of the function but the others can be patterns.
@yannham is there an other issue to link?

@github-actions github-actions bot temporarily deployed to pull request January 12, 2022 15:31 Inactive
@yannham
Copy link
Member

yannham commented Jan 12, 2022

I think we also want destructuring to work on such function definitions.

@yannham
Copy link
Member

yannham commented Jan 13, 2022

Oh, and we also want those when defining record fields, like { foo : Num -> Num, foo x y = x + y}

@mboes
Copy link
Member

mboes commented Jan 13, 2022

I think we want to punt on this to post release and until we have more code written in Nickel, for the same reason as discussed in #494 (comment).

@yannham
Copy link
Member

yannham commented Jan 13, 2022

Even in the light of #494 (comment) ?

Now able to use patterns destructuring in let functions syntax
also added simple tests
@github-actions github-actions bot temporarily deployed to pull request January 13, 2022 15:15 Inactive
@francois-caddet
Copy link
Contributor Author

I don't know well this syntax but will see. If it's not a lot to implement I will do it for this PR.

@mboes
Copy link
Member

mboes commented Jan 13, 2022

Sorry, what I meant in that comment is that this clearly needs a solution eventually. But since this is only syntactic sugar, would be good to gain experience first. If there was only one possible design here that would be one thing. But multiple designs are reasonable, including changing the syntax for functions everywhere, so that no syntactic sugar for lets is necessary. Further, it feels to me like there are higher priorities ahead of the release.

@francois-caddet
Copy link
Contributor Author

So we'll see later.

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

Successfully merging this pull request may close these issues.

None yet

3 participants