The postfix dash arg flag- convention is brilliant in helping to grasp the flipped structure
, yet it’s still unusual.
Thinking aloud here… UIUA language has an interesting idea reducing the weirdness for the majority used to prefix style:
Code runs from right to left, top to bottom
So they write ÷ [2 3] [6 9] but execute right-to-left “push [6 9]; push [2 3]; divide” order (result being [3 3]).
However, that requires parsing the whole program before execution, which conflicts with adding a REPL, and that’s where their second twist comes in:
Multiple lines do execute top-to-bottom, so this:
[2 3] [6 9]
÷
or even
[6 9]
[
2
3
]
÷
are equivalent!
So perhaps that way you could have a familiar-looking -combinator -flag arg -flag arg order, with full stack + REPL power?
Admittedly, the REPL order is still weird, it violates “enter ~ space” axiom of regular text wrapping! I haven’t really played with Uiua, don’t know yet how that feels… But, it kinda “postpones” the weirdness, one needs to grok that only when one graduates from CLI to REPL.
-
eliot makes good points, that the natural order may depend on your domain. Unix CLI conventions are already mixed-order in a way! E.g. jq syntax deliberately adopted pipe operators so that
jq 'foo | bar'would be equivalent tojq 'foo' | jq 'bar'. It’s hard for me to say where prefix/postfix fits your needs… -
IIUC you picked concatenative not so much for programming (e.g. do you define any shorthand aliases for common chunks of options?) as for easy way to implement a DSL that can express hierarchical structure?
I must say it’s unclear to me why a flat syntax is better here than say JSON. Or almost any DSL syntax with parens of some kind; It feels like nesting would make most examples here clearer to read…
And/or the whole thing would be clearer with diagrams.
P.S. if you haven’t seen “storage combinators” e.g. metablog: Native-GUI distributed system in a tweet that might interest you, e.g. cache- is similar spirit.
[P.S. using execline in one example made the doc even more obscure, but I’m glad to discover it — it’s really similar to ideas I hoped to explore
]