Arc Forumnew | comments | leaders | submit | eds's commentslogin

First-class macros? Anyone?

If not the macros than more ergonomic error messages.

-----

3 points by tokipin 6658 days ago | link

as a lisp noob i'm curious what specific sorts of things you could do with first-class macros. perhaps swapping out macros for a given macro call? say in one pass of a program (function) a particular macro call is expanded by macro1, and in the second pass the macro call is expanded by macro2

-----

6 points by kens1 6658 days ago | link

The problem I ran into today was:

  arc> (apply or '(nil t nil))
  Error: "Function call on inappropriate object #3(tagged mac #<procedure>) (nil t nil)"
I assume that first-class macros would let me do this.

-----

4 points by nex3 6658 days ago | link

There are folks here who know more about this than I do, but I think first-class macros would be very useful for creating a pure-Arc module system.

-----

2 points by eds 6658 days ago | link

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 6656 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 6656 days ago | link

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

-----

1 point by nex3 6658 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 6658 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 6658 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.

-----

1 point by eds 6659 days ago | link | parent | on: Getting started question

Looks like part of the mzlib standard library wasn't installed correctly. You might want to check if the file "/usr/lib/plt/collects/mzlib/port.ss" is actually there or not. If not, perhaps reinstalling might fix the problem.

-----

1 point by eds 6659 days ago | link | parent | on: Arc2.tar

Yes, the Anarki git repo has a fix for this.

http://arclanguage.org/item?id=3647

There is also Anarki Stable which consists of only arc2 and bug fixes.

http://arclanguage.org/item?id=3849

-----

1 point by czoon 6658 days ago | link

thanks i ll try

-----

1 point by czoon 6651 days ago | link

from http://jfkbits.blogspot.com/2008/01/digging-into-arc-in-24-m...

(xdef 'mkdir (lambda (path) (make-directory path))) redefine mkdir. its solves problem.

-----

1 point by eds 6659 days ago | link | parent | on: arc-exe.scm now fully compatible with ac.scm

What would arcc.sh do exactly?

-----

1 point by nex3 6659 days ago | link

I guess I didn't really understand arc-exe all that well - I thought it was compiling Arc code, but I guess it's compiling Arc itself. Oops :-p.

It might still be nice to have a build-arc-exe.sh file or something.

-----

6 points by eds 6659 days ago | link | parent | on: what does x!y do

y!x is short for (y 'x), and y.x is short for (y x)

It should also be noted that a.b and a!b only works when a and b are symbols or integers. You can't for example

  car!(1 2 3)
To do this correctly you first have to store the list in a variable

  (= l '(1 2 3))
  car.l
http://arclanguage.org/item?id=2166

-----

1 point by eds 6660 days ago | link | parent | on: Ensure-dir broken again on Windows

Great. Now we just need those changes in arc-exe.scm. I can probably get around to it sometime today, but I have homework I need to do first....

-----

2 points by eds 6660 days ago | link

Ok, I've been working, and I've copied the atomic invoke, which-os, make-directory and make-directory* , and datetbl fixes from ac.scm.

That resolves the most recent issues, but I've been looking through the code in ac.scm and arc-exe.scm and there are still major differences. For example, while looking at the change from * call* to call*, I found that arc-exe.scm never got the defcall change in the first place. So keeping arc-exe.scm compatible with ac.scm is not just an issue of changes from now on, because the two files are already somewhat divergent.

On the other hand, if we got arc-exe.scm to just load ac.scm somehow, we wouldn't have to worry about all this. Unfornately this may not be easy; I threw myself at the problem for a couple of hours and didn't really come up with anything, except for a severe dislike for scheme's module system.

-----

2 points by almkglor 6660 days ago | link

This is what I suggested to sacado:

http://arclanguage.com/item?id=3857

Sorry I can't be more help, I'm at the office right now building devices^^.

-----

1 point by eds 6659 days ago | link

Fortunately, nothing that fancy is necessary:

http://arclanguage.org/item?id=4000

-----

1 point by eds 6660 days ago | link | parent | on: Ensure-dir broken again on Windows

I should also point out that in the definition of mkdir, the line including (null? ,parents) probably doesn't do what you want it to since t isn't true and nil isn't null in scheme:

  arc> (= parents t)
  t
  arc> ($ (null? ,parents))
  Error: "reference to undefined identifier: t"
the fix should be to use ar-false? and quote the value of parents

  ($ (ar-false? ',parents))

-----


There are two "comments" links, one at the top of the page for all new comments, and one at the bottom of your profile page for all comments you posted.

I find the personal "comments" page very useful for finding all responses to comments I posted.

-----

1 point by eds 6660 days ago | link | parent | on: Anarki Stable

> Everyone has exactly the same amount of time: 24 hours in a day.

Except for Le Monte Young :)

-----

1 point by almkglor 6660 days ago | link

And Chuck Norris

-----

2 points by eds 6660 days ago | link | parent | on: On the naming of $

There is still seval, right? You could use seval rather than $ in the stable branch, since it won't have to be updated except for arcn releases and bug fixes, so maintenance won't be too much of a problem. And it doesn't require writing entirely new library functions to implement.

-----

3 points by nex3 6660 days ago | link

I'm not sure why this would be any better than using $. I'd rather just add library functions and be done with it.

-----

More