Open zetah11 opened 1 year ago
I do think fun
is somewhat aesthetically pleasing, for lack of a better term. The big reason I want to merge the two is because of stuff like let a + b = ...
, which doesn't really work with the current fun
-based syntax. Making it work would effectively remove the need for fun
anyways.
The big troublesome thing here is the potential ambiguity with constructors and pattern matching later on (e.g. does let some x = ...
(incorrectly) unpack an option type, or is it defining a function named some
?). The solution I'm leaning towards is requiring some path name in constructor names (e.g. Option.some
), which wouldn't be a valid function name anyway. This might require some more thought, though.
For parsing reasons,
let
always binds a value, whilefun
is a shorthand for functions. My intention before starting this project was to distinguish in a slightly different way:let
is an eager binding, whilefun
is a lazy binding; both can use the<kw> name arg1 arg2 ... =
shorthand syntax for declaring functions. Though this eager/lazy thing might be somewhat of a dead end, I still think it would be nice and simple if the language needed just one keyword for binding.One question is how this will interact with constructors, when that time comes. The short answer is "I don't know"; the long answer is that I might want to say that "constructors must always appear in qualified form" which would make parsing easier - if the application pattern has a raw name in the function part, it's a function; if it is a path, it's a constructor. But there are many options to explore here and things to consider.
Pros
"let" simple-expr "=" expr
let
always introduces a value in a nice"let this expression be defined as this expression"Cons
let
andfun
might make code ever so slightly more readable