Arc Forumnew | comments | leaders | submitlogin
1 point by aw 5222 days ago | link | parent

Yes. (That's what I meant by "the helper functions can be defined with a plain 'define' instead having to use 'define-for-syntax'")

But it then doesn't work with modules for the same reason. So it's not a solution yet, it just pushes around what doesn't work from one place to another.



1 point by aw 5222 days ago | link

Hmm, we should think about whether we'd want to use Racket modules anyway. Racket macros are more expressive (albeit harder to write) than Arc macros because they operate on syntax objects. But Racket modules don't seem very expressive to me: they aren't first class objects and they aren't parameterizable.

I'm guessing that a module system in the spirit of Arc would correspond more to Racket namespaces. Maybe I ought to be able to say something like:

  (module arc
    (load "foo.arc")
    (bar))
which creates a new namespace, populates it with values from the arc namespace, evaluates the expressions within that namespace, and returns the namespace. Or something like that.

-----

1 point by Pauan 5221 days ago | link

Which, incidentally, is already possible with namespaces + eval accepting a second parameter:

  (mac module (name . body)
    `(let ,name (new-namespace)
       (eval '(do ,@body) ,name)
       ,name))
Such a tiny change (namespaces + eval) has a lot of power, I think. Personally, I'd prefer this:

  (w/namespace (new-namespace)
    (load "foo.arc")
    (bar))
Because then you can do this:

  (import foo "foo.arc"
          bar "bar.arc")

  (w/namespace foo
    ...)

  (w/namespace bar
    (load ...)
    (load ...)
    ...)

  (w/namespace (current-namespace)
    ...)
  
  (w/namespace (current-environment)
    ...)

  (w/namespace (table)
    ...)
But it's not a big deal, since both `module` and `w/namespace` are easy to write as macros. So you can use whichever you want. :D

-----

1 point by aw 5221 days ago | link

So it's not a solution yet

On the other hand, if namespace modules do turn out to be a good idea, then it doesn't matter that it doesn't work with Racket modules :)

-----