Hacker News
Rethinking Syntax: Binding by Adjacency
derefr
|next
[-]
The formal name for the “empty” binary infix operator that gets implied in the AST when doing this, is the “juxtaposition” (or “juxtapose”, or “juxt”) operator. The implicit multiplication operator between `3` and `a` in the polynomial expression `3a + 4`, and the implicit function-application operator in the Lambda-calculus expression `f x y`, are both instances of an implied juxtaposition operator (with different semantics for it in each of the two cases, as befits each type of algebra/calculus.)
layer8
|next
|previous
[-]
It’s similar for the human reader: The examples are only intelligible to the reader incidentally, due to the names used and some natural-text conventions. In the general case, you have a seemingly random token sequence where you have no idea what binds to what, without looking up the type definitions or having an IDE present the expression in some structured way again.
Furthermore, in typical code you don’t have the case of constant values so often. You’ll rather have things like:
nextYear thisMonth.previous() lastDayOf(thisMonth.previous())
Double.parse(speedInput) m/s
startPos to (startPos + length - 1)
Schedule contacts.select(contactId) inputForm.getDateTime()
owlstuffing
|next
|previous
[-]
2025 July 19 // → LocalDate
300M m/s // → Velocity
1 to 10 // → Range<Int>
Schedule Alice Tues 3pm // → CalendarEvent
That's the idea behind binding expressions — a compiler plugin I built to explore what it would mean if adjacency had operator semantics. It lets adjacent expressions bind based on their static types, forming new expressions through type-directed resolution.Details here: https://github.com/manifold-systems/manifold/blob/master/doc...
evanb
|next
|previous
[-]
This seems like a great attempt. I would be worried about how much parsing and backtracking might be required to infer the infix precedence in a totally general system (like garden-path sentences[1]) or actually ambiguous parse trees (which is cured by adopting some rule like right precedence and parens, but what rule you pick makes some 'natural language' constructions work over others).
nxobject
|root
|parent
[-]
tgv
|next
|previous
[-]
You could of course affix all lemmata with structural information, as free word order languages do, but that's introducing syntactic structure via the backdoor.
jnpnj
|next
|previous
[-]
thesz
|next
|previous
[-]
[1] https://www.researchgate.net/publication/2743686_Are_Ours_Re...
So, yes, it can be done and it was done. Yes, expressiveness rises. No, reading comprehension of such languages does not suffer. Yes, it has to have a lot of scaffolding.
bawolff
|next
|previous
[-]
measurablefunc
|previous
[-]
antonvs
|root
|parent
[-]
If you added a function to the examples, you could do a few of them, e.g.:
2025 July 19 date
299.8 M m / s velocity
But even this breaks down when you get to something like “Meet Alice Tuesday at 3pm”. Sure, you could contort things to make it resemble the concept, but it’d be a stretch at best.