0x0f0f0f / gobba

A purely functional dynamically typed programming language.
https://0x0f0f0f.github.io/gobba-book/
MIT License
56 stars 2 forks source link

Should types representing functions to be moved to a single-argument nested style? #7

Closed 0x0f0f0f closed 4 years ago

0x0f0f0f commented 4 years ago

Should the definition for function expressions be like this

type expr = 
...
| Lambda of ide * expr

so that a function that takes 3 arguments becomes (Lambda ("x", (Lambda ("y", Lambda ("z", ...body...))))

Or should i keep the list style?

type expr = 
...
| Lambda of ide list * expr

where a function that takes 3 arguments is (Lambda (["x"; "y"; "z"], ...body...)

I think the latter is easier to read, but the first one makes currying and static type inference easier.

cheery commented 4 years ago

Do the first one if you're doing ocaml-style language. If you'll optimize lambdas by clumping them together, it'll be likely in this way: x → y → z → body ==>> (x ∧ y ∧ z) → body, not by RLE-encoding original structures.

0x0f0f0f commented 4 years ago

Chose the first one. Closing. A lot of things like partial application now snap together nicely. Thank you!