3 ms·
Python has a data structure like this called NamedTuple. I also noticed it's popping up everywhere, in this case sql rows (kind of). Conceptually I like the id
by erezsh 5y ago
Python has a data structure like this called NamedTuple.
I also noticed it's popping up everywhere, in this case sql rows (kind of). Conceptually I like the idea of using it as the mechanism for function arguments, but I didn't want the syntax to be too confusing for beginners.
Although yours seems a little bit different, because different fields can have the same name.
Just for the heck of it, here's how your second example would look in preql:
(stops
{ lat, lon => }
{ lat => lon: min(lon) }
{ lon } // not necessary. just drops the lat column
)
- dvdkon 5y agoIt's not quite that arg-tuples can contain multiple values under the same name, but rather ":a 1, :a 2" is actually an arg-tuple containing two nested arg-tuples as unnamed values. I agree that basing all of syntax on a single element (especially one that's so "light" on syntax), it's hard making the resulting syntax intuitive. I think it's worth it, but I can see other approaches' benefits.
- erezsh 5y agoIt's definitely an interesting approach. I imagine it makes the parsing much easier.