Arc Forumnew | comments | leaders | submitlogin
16 points by absz 6144 days ago | link | parent

Not quite. Arc has various bits of (gasp!) syntax. There are 10 pieces of syntax: () [] ' ` , ,@ ~ : . and ! . A quick breakdown:

1. () you know--function application, macro application, or a list. Basic stuff.

2. [] creates an anonymous function of 1 (or, on the Anarki, n) arguments. [...] is transformed (more or less) into (fn (_) ...).

3. '... is the same as (quote ...); whatever is inside becomes a literal. 'a is a symbol, '(a) is a list....

4. `... is the same as (quasiquote ...); the same as (quote ...), but evaluated things can be inserted with (unquote ...) and (unquote-splicing ...).

5. ,... is the same as (unquote ...); as observed, `(.1. ,... .2.) is similar to (list '.1. ... '.2.).

6. ,@... is the same as (unquote-splicing ...); the same as unquote, but ... must be a list and is spliced in. `(.1. ,@... .2.) is similar to (join '(.1.) ... '(.2.)).

7. ~func is the same as (complement func), which returns a function which is conceptually similar to (fn __ (no (apply func __))), i.e. which returns the boolean opposite of whatever the original returned.

8. f1:f2 is the same as (compose f1 f2), which returns a function which is conceptually similar to (fn __ (f1 (apply f2 __))), i.e. which applies f1 to the return value of f2 applied to the arguments.

9. x.y is the same as (x y); it's designed for nice structure access, e.g. lst.3 instead of (lst 3).

10. x!y is the same as (x 'y); it's also designed for nice structure access, e.g. my-table!password instead of (my-table 'password).



3 points by kens1 6144 days ago | link

Good explanation. As an aside, the four syntax characters "~ : ! ." are the "special syntax". You can see the effects of these with ssexpand. Also, ~ and : can be combined, and ! and . can be combined, but not the other combinations (e.g. ~ and !).

  arc> (ssexpand '~a:b:~c)
  (compose (complement a) b (complement c))
  arc> (ssexpand 'd.e!f)
  (d e (quote f))
I just noticed that (car (ssexpand '.a)) returns the Scheme eof object. This doesn't seem like a good thing.

-----

4 points by absz 6144 days ago | link

Good point. To be precise (as you noted), () [] ' , and ,@ are taken care of by mzscheme's read, but ~ : . and ! are handled afterwards in ssexpand (or its equivalent in ac.scm).

There are other bugs like those--pretty much any special syntax character on its own or in an incomplete way becomes an EOF.

-----