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

Design syntax for function parameters and lambdas #633

Open
CohenArthur opened this issue Oct 26, 2023 · 4 comments
Open

Design syntax for function parameters and lambdas #633

CohenArthur opened this issue Oct 26, 2023 · 4 comments
Labels
design Issue or concerns regarding jinko's design parser Parser issue

Comments

@CohenArthur
Copy link
Member

// switch from
func map[T, U](value: Maybe[T], f: func(T) -> U) -> Maybe[U] {}

// to
func map[T, U](value: Maybe[T], f: T -> U) -> Maybe[U] {}
@CohenArthur CohenArthur added parser Parser issue design Issue or concerns regarding jinko's design labels Oct 26, 2023
@Skallwar
Copy link
Member

What this will looks like when f take more than 1 arg?

func map[T, U, V](value: Maybe[T], f: T, V -> U) -> Maybe[U] {}

@CohenArthur
Copy link
Member Author

What this will looks like when f take more than 1 arg?

func map[T, U, V](value: Maybe[T], f: T, V -> U) -> Maybe[U] {}

I was thinking something like

func map[T, U, V](value: Maybe[T], f: (T, V) -> U) -> Maybe[U] {}

which would also be the same syntax as having one tuple argument to the function, so I don't know if it's good or bad. Swift has had issues with this feature, but it's also a way more complex language, so maybe we can adopt it and not suffer: https://stackoverflow.com/questions/31320714/tuple-and-function-argument-in-swift

@Skallwar
Copy link
Member

What the issue with the current syntax?

@CohenArthur
Copy link
Member Author

it just looks less nice to me, I'd rather type int -> string than func(int) -> string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Issue or concerns regarding jinko's design parser Parser issue
Projects
None yet
Development

No branches or pull requests

2 participants