Hi Samuel,

> Are there more efficient ways to sanitize the created namespaces? I am not
> sure if there is a better way than zap-ping the heck out of any symbol that
> is not explicitly used in the namespace.

In pil64 you could achieve that with a trick. You can create an empty

   : (setq ns '(NIL))
   -> (NIL)

and then go ahead and fill it with symbols, e.g.:

   : (de ns~cube (X) (* X X X))
   -> "cube"

In ErsatzLisp, however, this might not be so easy. Perhaps you can use
reflection to initialize 'ns' with a Java 'Namespace' object?

Having said this, however, I think that using namespaces in that way
violates the idea of namespaces. Such an "amputated" namespace can't be
used as the current namespace, by setting it active

   (symbols 'ns)

because it lacks most symbols needed in the course of further
programming. So you will use the above 'cube' always with the namespace
prefix 'ns~cube'. If so, then why use a namespace at all? Instead, you
could as well use some other delimter like '-' or '.' and define those
symbols directly in the current namespace

   : (de ns.cube (X) (* X X X))
   -> ns.cube

Calling (ns.cube ..) is semantically equivalent to (ns~cube ..)

A question: In your code, I don't understand why you 'intern' and
immediately 'zap' some symbols, e.g.

>         (zap (intern "new"))
> ...
>         (zap (intern Symbol))

I see that as a null-operation. Or did I forget some side-effect?

### Some other notes, tips or questions:

## 1
>     ... (last (split (chop Class) "."))

this can be slightly simplified to

      ... (stem (chop Class) ".")

## 2
>       (zap (intern "new"))
>       (def (intern (pack "new"))

What is the purpose of 'pack' here? I think the above can be replaced

         (zap 'new)
         (def (intern "new")

## 3
>         (curry (Class) @
>           (apply 'java
>             (append
>               (list Class T)
>                 (rest) ) ) ) )

In a function with variable arguments (i.e. with the '@' special formal
parameter), (apply .. (rest)) can generally be replaced with 'pass'. So
the above would reduce to (not tested ;-)

        (curry (Class) @
          (pass java Class T) )

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to