Arc Forumnew | comments | leaders | submitlogin
3 points by rocketnia 4830 days ago | link | parent

Unless you've memorized every macro's inner workings it's clearly open to more than one interpretation.

That's the thing. To interpret (case ...) at all, you have to know what 'case is supposed to do as a macro. At least one suggestion on this forum (http://arclanguage.org/item?id=10858) would intentionally(?) have your example work in a different way:

  (case x 'y (dosomething))
    == reads as ==>
  (case x (quote y) (dosomething))
    == expands to ==>
  (let gs123 x (if (in gs123 'quote 'y) (dosomething)))
When I started out with lisps, I had trouble with this. I kept reading (quote x) as though it might evaluate x, or (let ((foo bar)) ...) as though it might involve a function call to foo. It wasn't just a matter of vocabulary; even if I figured out what (quote ...) did, some macro form around that code might give it a completely different meaning! What if one of these unintelligible commands had the side effect of rebinding 'quote? It took me a while to realize lisp programmers weren't quite as sadistic as that, but that revelation in itself doesn't make the whole issue go away. ^_^ You sorta do have to memorize every macro.

Of course, we could just go for read macros everywhere, rather than putting cheap abbreviations into the normal macros:

  ; assuming 'x abbreviates (quote x), which it does
  (obj 'key "value")
  
  ; assuming #'x abbreviates (fn () x)
  (if condition
    #'then
    #'else)
  
  ; assuming #,x abbreviates (fn (gs123) (zap gs123 x))
  (push elem #,place)
  
  ; assuming #. var x y z abbreviates (fn (var) x y z), with the read
  ; macro terminating once a mismatched closing parenthesis is reached
  (w/outstring #. var
    body1
    body2
    body3)
  
  ; assuming all of the above
  (mac #,case (var . body)
    (w/uniq #. g-var
      `(let var #. ,g-var (case-part-2 ,g-var ,@body))))
  (case x #''y #'(dosomething))
A good portion of the macros I write do nothing but prevent the need for these abbreviations (except they do put the #. variable in a more idiomatic spot), so it's a significant move. I kinda intended to show how bad it was, but what do you think? If we found hieroglyphics we could get used to, maybe they wouldn't be bad at all....