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).
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. var myDate = MAGIC"2025 July 19"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()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.
owlstuffing•1d ago
Details here: https://github.com/manifold-systems/manifold/blob/master/doc...