Arc Forumnew | comments | leaders | submitlogin
Strangeness with set and macros
7 points by kens 6143 days ago | 5 comments
The behavior of set seems a bit strange to me:

  arc> (set (and a) 42)
  42
  arc> (set (or b) 42)
  Error: "First arg to set must be a symbol ((fn (gs1439) (if gs1439 gs1439 (or))) b)"
This happens because "and" macroexpands to a symbol and "or" expands to a fn. It also happens because macro processing goes through a special case (ac-setn/ac-macex) if the macro is in the first position of a "set". And "set" macroexpands but doesn't evaluate the argument.

I don't think this is a bug per se, but this behavior bothers me. It seems to expose details of how the arguments are implemented. (This isn't tied to "and" and "or" specifically; they are just examples.)

Does anyone else think this behavior is strange?



3 points by cooldude127 6143 days ago | link

I would be more concerned, but there is not really a way to fix this without changing the semantics of set. Set doesn't eval it's first argument, so it expects an unquoted symbol. Get an operator that does the same thing, but evaluates its arguments, and you will be fine.

-----

2 points by cchooper 6143 days ago | link

I do, but then consistency is not something I've come to expect from Arc. It's a consequence of the empirical design: Arc is optimized for the common, practical case, rather than being designed according to a pre-conceived plan (or even a post-conceived plan).

-----

4 points by almkglor 6143 days ago | link

Perl

-----

2 points by cchooper 6143 days ago | link

Let's hope not.

-----

0 points by almkglor 6143 days ago | link

^^

-----