Hi all,

with the newest release (17.3.4) in software-lab.de/picoLisp.tgz, namespace
handling in Pil64 has changed a little.

Until now, there was always always a single active namespace, which was created
with the 'symbols' function, and contained a full copy of the argument

This made the internal symbols lookup (i.e. the read and print functions) simple
and fast. The drawback was a relatively large memory footprint (about 25 KiB per
namespace), and no satisfactory control over namespace-local symbols.

In the new version, we have not a single namespace, but a list of separate
namespaces, specifying a clear search order. New namespaces are empty, and grow
only as big as necessary. When printing a symbol, the namespace prefix can be
printed as it is now known in which namespace the symbol resides.

The programming interface did not change very much.

'symbols' now returns a list of namespaces for the current search order.

The only significant change is 'local', which used to be called with symbolic
arguments as

   (local abc def ghi)  # Old version

but now needs to be called in a bit unusual way: It takes no "normal" arguments,
but 'read's a list of symbols from the current input channel. In praxis, this
means the list of symbols is directly written after (local):

   (local) [abc def ghi]


   [abc def ghi jkl]


   (local) [
      abc def ghi
      jkl mno pqr

or similar. I'm using super parentheses here to make it visually clear, but of
cours normal ( .. ) parentheses can be used as well.

This access of the symbols in this list is done by 'local' only in the first
namespace of the current search order, causing these symbols to be found or
created in that namespace, giving truly local symbols.

A typical source file would have a 'symbols' and a 'local' call in the beginning
(and perhaps more 'local' calls later)

   (symbols 'lib1 'pico)
   (local) [foo bar]

   (de foo () ..
   (de bar () ..

while another might be

   (symbols 'lib2 'lib1 'pico)
   (local) [mumble]

   (de mumble ()
      (foo ..) )

Many other combinations are possible, e.g.

   (symbols 'lib2 'pico)
   (local) [mumble]

   (de mumble ()
      (lib1~foo ..) )

Symbols from other namespaces can be overshadowed

   (symbols 'lib1 'pico)
   (local) [put get]

   (de put ()
      (pico~put ..)  # Call the built-in 'put'

   (de get ()
      (pico~get ..)

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

Reply via email to