Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  (mapdo .start-time.(set 42) obj-list)
  (swap [a 2..4] [b 0..2])
This looks gross. Why does no one seem to understand that lisp should not have infix operators?


I respect the idea that Lisp syntax should only be based on dispatch based on looking at the leftmost input character.

In TXR Lisp, I decided to experiment with a small number of notations, to see whether they could make Lisp coding a bit more ergonomic, similarly to how 'x has helped with (quote x) for over sixty years.

There are rules: the notations have to absolutely fit into the surrounding Lisp.

The notations all have an underlying equivalent tree structure: list headed by a specific symbol.

There must be print-read consistency.

Not all combinations of the underlying structure need to (or should) map to the notation.

  1> '(qref a b c d)
  a.b.c.d
  2> '(qref a b (qref c d))
  (qref a b c.d)
  3> '(qref (qref a b) (qref c d))
  (qref a.b c.d)
  4> '(qref 1 0)
  (qref 1 0)
  5> '(qref 1 a)
  (qref 1 a)
  6> '(qref a 1)
  (qref a 1)
Not every (qref X Y) is blindly printed as X.Y, which would break print-read consistency. Multiple different qref nestings would map to the same notation, and (qref 1 0) would produce the floating-point token 1.0.

Of course, some of these notations complicate parsing. When we see a symbol token like a, we cannot just return the symbol, because it could be followed by a dot, in which case we are in (qref a ... syntax, or other possibilities.

Be that as it may, working with this stuff is fine; all in a day's Lisp.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: