Arc Forumnew | comments | leaders | submitlogin
2 points by eds 4586 days ago | link | parent

I'm not exactly an expert on this, but I think it would allow you to put a macro literal in functional position. Right now:

  arc> and
  #3(tagged mac #<procedure>)
  arc> (eval (list and 1 nil 2))
  Error: "Bad object in expression #3(tagged mac #<procedure>)"
So if you had theoretical first-class macros, you could do stuff like use backquote to protect a macro you use from being overridden. (This wouldn't be necessary if we had a module system, but that might require first-class macros itself.) So in the (contrived) example below, foo works fine because prs is a function, but bar fails because foo is a macro.

EDIT: Actually, function literals in functional position only works on Anarki. It might be nice to have that fix in the official version.

  arc> (mac foo args `(,prs ,@args))
  #3(tagged mac #<procedure>)
  arc> (mac bar args `(,foo ,@(keep [isa _ 'sym] args)))
  #3(tagged mac #<procedure>)
I think first-class macros might be useful in making infix math expansion occur at compile time rather than run time... but I'm not completely sure on that one.


4 points by Jesin 4584 days ago | link

Yes, please. First class macros and the ability to use macros and functions (rather than just their names or definitions) in functional position would be great, and macro names would not have to shadow variable names gobally anymore. In my opinion that is one of the biggest problems with Arc.

-----

2 points by sacado 4583 days ago | link

Oh, yes. That one drove me crazy a few times.

-----

1 point by nex3 4586 days ago | link

fns in functional position work fine for me in arc2... can you give an example where they die?

-----

3 points by eds 4586 days ago | link

  arc> (eval (list + 3 4))
  Error: "Bad object in expression #<procedure:...mming\\Arc\\ac.scm:602:9>"

  arc> (mac foo args `(,+ ,@args))
  #3(tagged mac #<procedure>)
  arc> (foo 3 4)
  Error: "Bad object in expression #<procedure:...mming\\Arc\\ac.scm:602:9>"

-----

1 point by nex3 4586 days ago | link

Oh, I thought you meant function literals as in calls to fn. But calling functions from lists... yeah, that would be great to have.

-----