Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4531 days ago | link | parent

What do you mean by "lifting Scheme primitives"?


2 points by akkartik 4531 days ago | link

I mean the $ primitive:

http://github.com/nex3/arc/blob/6132d33e09/ac.scm#L49

Example of its use:

http://github.com/nex3/arc/blob/6132d33e09/lib/re.arc

(The regexp- functions are from racket.)

-----

1 point by Pauan 4531 days ago | link

Okay, I'm still not sure what you mean by "lifting Arc primitives" but I'll do my best to explain how Nu works.

The compiler itself is written in Arc's namespace. There is no separation at all between Arc, the Arc compiler, and Racket: everything is cobbled into one giant namespace. So changing the compiler is as simple as writing an Arc function/macro. This is how ar works, and I liked it enough that I copied the idea for Nu.

That also means no need for the $ primitive because all Racket stuff is prefixed with `racket-`. Thus you would say `racket-regexp-match` rather than `$.regexp-match`.

Note: it's possible to import Racket modules with any prefix you like (including no prefix), but it's there mostly to avoid namespace collisions with Arc stuff.

---

As for doing the same thing with Arc primitives, I assume you mean that if you create a new namespace, you might sometimes want to use the definitions in the new namespace, and sometimes the definitions in Arc's namespace.

You can do that too, by calling eval-w/ with arc3-namespace:

  (eval-w/ arc3-namespace
    foo)
Because it's common enough to want to load things into Arc's namespace, the above can also be expressed as w/arc3:

  (w/arc3 foo)
That will give you the definition of "foo" from Arc's namespace. This shouldn't be necessary most of the time because it's possible to have a namespace inherit from another. In that case, if the variable isn't found, it'll search in the parent.

Thus, if you make a new namespace that inherits from Arc's namespace, you'll automatically get all the Arc stuff for free. That's how Arubic works: it makes a namespace that inherits from Arc, and then changes things. Anything that Arubic doesn't change is automatically taken from Arc.

-----

1 point by akkartik 4531 days ago | link

Ok perhaps your namespaces are the simplest way to 'lift' arc into Nu.

If you implement language A in language B, A is above B in the stack. It's meaningless to call A's code from B, but useful to call B from A. The latter is what I call lifting. But I realize this terminology doesn't work for anything but simple static compilation.

-----

2 points by Pauan 4531 days ago | link

"It's meaningless to call A's code from B"

If I wrote an awesome library in Arubic, especially a library that would be difficult to port to Arc, and you wanted to use the library, but didn't want to use Arubic, it would be very useful to write Arc code that used said Arubic library.

As another example, you may want to write a module in Racket that imports a library written in Arc. Even though Arc is implemented in Racket, I don't see how that counts as "meaningless". This example isn't even theoretical, there was somebody on this forum earlier who wanted to do exactly that:

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

---

"but useful to call B from A."

That's handled by the w/arc3 form, which as already said is not needed most of the time, due to inheritance.

-----