Arc Forumnew | comments | leaders | submitlogin
Why make-br-fn?
2 points by evanrmurphy 5010 days ago | 5 comments
In Arc 3.1,

  [_]
is ssexpanded directly to

  (fn (_) (_))
whereas in Anarki it goes through the intermediate make-br-fn. What's wrong with the direct expansion? I tried searching this forum for an explanation but couldn't find one.


6 points by waterhouse 5010 days ago | link

Probably so that it can be changed more easily (by redefining 'make-br-fn rather than hacking the reader).

  ;arc.arc from Anarki
  (mac make-br-fn (body) `(fn (_) ,body))
I recall at one point people talking about making brackets work so that, for example, [+ _x _y _z] = (fn (_x _y _z) (+ _x _y _z)). It would extract all arguments from the body beginning with _, alphabetize them, and insert them into the argument list. I don't know if Anarki actually did this, but I do believe it accepted [+ _1 _2 _3 ...] at one point.

See also: http://arclanguage.org/item?id=1227, http://arclanguage.org/item?id=8947, http://arclanguage.org/item?id=8617

-----

1 point by rntz 5008 days ago | link

I implemented that feature (multiple automatic parameters, with alphabetic ordering, so [cons _y _x] = (fn (_x _y) (cons _y _x))) in anarki. I don't know for sure, but I would assume it's still there.

-----

1 point by evanrmurphy 5010 days ago | link

OK, that makes sense. Thanks for the links.

-----

3 points by rntz 5008 days ago | link

Nitpicking: that's not ssexpansion. Ssexpansion is short for symbol-syntax expansion, in which the occurrence of special characters in symbols tells the arc compiler to transform them, things like foo.bar -> (foo bar), foo!bar -> (foo 'bar). The brace transformation is actually accomplished via changing the reader table of the underlying scheme, and so is translated at read-time rather than compile-time.

This is important if, eg, you're writing scheme code to integrate into the arc runtime in some fashion; normally, in plt scheme, braces [] and parentheses () are interchangeable; but arc changes the way [] is parsed, so you basically have to avoid using them in scheme code. Whereas ssyntax is parsed by the arc compiler, not the reader, so you don't need to worry about it.

-----

1 point by evanrmurphy 5008 days ago | link

Ah, you're right! I had thought it was ssexpansion because of

  arc> (ssexpand '[_])
  (fn (_) (_))
but it turns out to expand even without ssexpand:

  arc> '[_]
  (fn (_) (_))
Thanks for the clarification. ^_^

-----