Arc Forumnew | comments | leaders | submitlogin
Dual syntax for Arc
1 point by thefifthman 6184 days ago | 6 comments
Paul Graham often quotes that programs should be readable, and that programs should be for people, not for machines. I think that a lot of people find mixfix syntax much more readable than prefix notation (most mathematicians belong to this class of people...). Let's face it, a + b + c is easier to read than (+ a b c), especially when there are subexpressions and so on. On the other hand I totally agree that when manipulating programs via macros, I should not be bothered with these syntax details which just annoy then. So why not allow both? The prefix notation is the streamlined internal representation, but the user can also choose to employ mixfix notation when writing down Arc programs (of course, he can also choose to just use plain prefix notation). There should be some grammar-based mechanism of associating such syntactic sugar to operators like "if", "+", or your own favourite homegrown operator "magicwand".


3 points by absz 6184 days ago | link

See also http://arclanguage.org/item?id=3477 for an infix macro, which should do most of what you want.

-----

1 point by sacado 6184 days ago | link

Actually, you already can.

First, mzscheme lets you use this syntax :

(a . + . (b . + . c))

Well, I find it ugly and hard to type (that's about 20 characters, instead of about 10), but that's a question of point of view, and at least you can do that.

There was also an experimental version of infix notation for numerical operations on Anarki a few time ago. You could do :

(a + b + c)

However, the implementation was very slow, so I think it is not used by many of us those days.

-----

2 points by eds 6183 days ago | link

> However, the implementation was very slow, so I think it is not used by many of us those days.

I'd like to find a way to improve the speed of the current infix implementation, but I'm not sure it can be done without using macros, which would require some sort of type inferencing or static type declarations.

-----

1 point by almkglor 6182 days ago | link

Or just:

  (nfx a + b - c)
An old dorky buggy implementation for CL:

http://www.dwheeler.com/readable/readable/trunk/gloria-infix...

-----

1 point by sacado 6183 days ago | link

Once again, maybe the solution is ssyntax (yep, this is my new motto :) :

  { a + b + c } <==> (+ a (+ b c))
Hmm, not an easy one though.

-----

1 point by absz 6183 days ago | link

The ssyntax system cannot do this: it's limited to working on symbols. You would need access to the readtables in mzscheme to make this work.

-----