CatalaLang / catala

Programming language for literate programming law specification
https://catala-lang.org
Apache License 2.0
1.98k stars 77 forks source link

Proper environment, including builtins #141

Open msprotz opened 3 years ago

msprotz commented 3 years ago

I think it's time for a general syntax for arbitrary function calls, not just built-in functions that each have their dedicated keywords.

I would envision things such as

definition foo equals builtin::min of (bar, baz)

where the namespace is optional

internally, this would be implemented as follows:

That way we don't rely on a limited set of known keywords (this does not scale, even with a hash table of keywords in the lexer) and we can make it feasible to extend the set of compiler built-ins. Also, this paves the way for proper handling of names once we have proper modularity.

Thanks,

Jonathan

AltGr commented 1 year ago

There are two parts in this:

Regarding these, this issue could be closed; however…

Builtins still have added power though, e.g. they can be overloads. More importantly, while there may be no need for them to be keywords, the parser is the only place at the moment where we handle multi-lingual input ; so this raises the question of how to handle internationalised libraries…