NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Rethinking Syntax: Binding by Adjacency (github.com)
evanb 10 minutes ago [-]
Mathematica has Infix [0], which expresses the adjacency with a ~ (because Mathematica reserves pure blankspace for multiplication). But it works fine to do eg. `"hello"~StringJoin~" world"`; I was always surprised we could only have the predefined operators in many other languages and we couldn't define our own.

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).

[0] https://reference.wolfram.com/language/ref/Infix.html

[1] https://en.wikipedia.org/wiki/Garden-path_sentence

owlstuffing 2 days ago [-]
What if these were real, type-safe expressions in Java:

    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...

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 19:24:26 GMT+0000 (Coordinated Universal Time) with Vercel.