3 ms·
I have long envisioned a language where these two things were tightly combined. The rough ideas are: - All arguments are keyword arguments. - Each function imp
by kevincox 6y ago
I have long envisioned a language where these two things were tightly combined. The rough ideas are:
- All arguments are keyword arguments.
- Each function implicitly defines a struct type equivalent to its arguments.
I think if you combined this with some nice structural typing you can get a lot of the argument forwarding/builders and similar that people enjoy in dynamic languages without much/any overhead. Rough example:
fn add(a: int, b: int): int {
a + b
}
fn add3(c: int, rest: add::args): int {
add(rest) + 3
}
A somewhat silly example but I think you can see the point. Of course you could also add language-level builder syntax to these structs and have something really nice.
I think the key here is that once you make the arguments a static type you can add loads of convenience like builders very easily.
- wwright 6y agoThis makes me wonder if there is some sort of relationship between currying and row polymorphism; that could be pretty sweet to capture succinctly in a language
- eeereerews 6y agoI've thought about this too, but keeping positional args. The basic data type would be a "blob", consisting of a struct part and a tuple part.
- MrBuddyCasino 6y agoArgs reified as structs, interesting! On the other hand, not exceptional at all when looking at it from a Lisp angle.