Arc Forumnew | comments | leaders | submitlogin
Should Arc support infix notation?
9 points by kens 6274 days ago | 8 comments
The funny thing is, Arc already has infix notation!

  arc> (2 . * . (1 . + . 2))
  6
  arc> (1 . cons . '(2 3))
  (1 2 3)
  arc> (x . = . 3)
  3
This is apparently a feature inherited from MzScheme: http://download.plt-scheme.org/doc/mzscheme/mzscheme-Z-H-11.html#node_sec_11.2.4


5 points by pg 6274 days ago | link

Good heavens.

Infix -> prefix is pretty easy to write. I probably already have several times. I could add a lib fn if there was demand for it.

-----

2 points by croach 6272 days ago | link

No, please don't add a library function for infix operations. I don't think it adds anything to the language other than clutter, and it becomes basically a crutch for those new to lisp that will just make it harder for them to transition to the lisp way of thinking.

-----

3 points by almkglor 6272 days ago | link

  (/ (- (sqrt (- (* b b) (* 4 a c))) b) (* 2 a))

  (nfx ((sqrt (b * b - 4 * a * c)) - b) / (2 * a))

-----

2 points by almkglor 6273 days ago | link

Make it a macro form:

  (nfx x = 1 + 2 - 3)

-----

4 points by greatness 6274 days ago | link

wow, good catch. Pretty sure it's not on purpose though. That syntax defies everything that dot notation means. Consider it supported for the same reason Arc has UTF-8 at the minute.

-----

0 points by ryantmulligan 6274 days ago | link

maybe..

-----

1 point by lojic 6274 days ago | link

UCBLogo seems to do a good job of allowing both infix and sexp.

  7 + 8
  sum 7 8
  (sum 7 8 9)

-----

1 point by almkglor 6273 days ago | link

So does the Lisplike of Cadence, called Skill:

  > (1 + 2)
  3
  > '(plus 1 2)
  (1 + 2)
  > (plus 1 2)
  3

-----