From: Daniel Pitts
Subject: Custom namespacing...
Date: 
Message-ID: <1192135977.204408.115690@19g2000hsx.googlegroups.com>
I'm working on a project that has the abstract concept of a "region"
and an "area".
I have a declarative section the describes these.
---
(region region-symbol-name)
;; declared areas after the next line belong in
;; in the specified region
(in-region region-symbol-name)
;; Create an area in this region
(area area-symbol-name)
;; other declared things will be "owned" by
;; the specified area
(in-area area-symbol-name)
;; declares something.
(something-that-affects-the-current-context some-things-symbol)
---
So, what I want to do is to have region-symbol-name be a global (or
package) symbol,
area-symbol-name be a symbol when the context includes region-symbol-
name, and have some-things-symbol be a symbol when the context
includes area-symbol-name.

Am I going about this the wrong way? Would I be better off using
nested lists? Am I missing something fundamental?
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

From: Richard M Kreuter
Subject: Re: Custom namespacing...
Date: 
Message-ID: <87wstt9ha0.fsf@progn.net>
Daniel Pitts <·············@coloraura.com> writes:

> I'm working on a project that has the abstract concept of a "region"
> and an "area".
> I have a declarative section the describes these.
> ---
> (region region-symbol-name)
> ;; declared areas after the next line belong in
> ;; in the specified region
> (in-region region-symbol-name)
> ;; Create an area in this region
> (area area-symbol-name)
> ;; other declared things will be "owned" by
> ;; the specified area
> (in-area area-symbol-name)
> ;; declares something.
> (something-that-affects-the-current-context some-things-symbol)
> ---
> So, what I want to do is to have region-symbol-name be a global (or
> package) symbol,
> area-symbol-name be a symbol when the context includes region-symbol-
> name, and have some-things-symbol be a symbol when the context
> includes area-symbol-name.
>
> Am I going about this the wrong way? Would I be better off using
> nested lists? Am I missing something fundamental?

Your use of the word "symbol" in the above is problematic: a symbol is
a defined Lisp type, and instances of the type get created under
various determinate circumstances.  In particular, when the Lisp
reader sees the samples above, REGION-SYMBOL-NAME, AREA-SYMBOL-NAME,
and SOME-THINGS-SYMBOL will be symbols.

(Further, there's no meaningful notion of global-ness or
non-global-ness for symbols: there are interned symbols and uninterned
symbols, but there's only the one world of interned symbols, really.)

So I think what you want to say is that you want REGION-SYMBOL-NAME to
be a name for a region in a global region namespace, for
AREA-SYMBOL-NAME to be a name for an area relative to the current
region, and for SOME-THINGS-SYMBOL be a name for something relative to
the current area, right?  If that's what you want, it's not very hard:
make REGION be an operator that associates its argument with a new
region in some implicit mapping structure (an alist or hash table,
say), IN-REGION be an operator that looks up its argument in the
mapping structure and assigns some implicit global variable to the
region, AREA be an operator that associates its argument with a newly
created area in some mapping that depends on the current value of the
implicit region, etc.  However, unless you're willing to quote some of
the symbols in source code, everything will have to be done with
macros.

--
RmK
From: Raffael Cavallaro
Subject: Re: Custom namespacing...
Date: 
Message-ID: <2007101122523775249-raffaelcavallaro@pasdespamsilvousplaitmaccom>
On 2007-10-11 16:52:57 -0400, Daniel Pitts <·············@coloraura.com> said:

> Am I going about this the wrong way? Would I be better off using
> nested lists? Am I missing something fundamental?

Have you looked at Tim Bradshaw's hierarchical packages?

<http://www.tfeb.org/lisp/hax.html#HIERARCHICAL-PACKAGES>

and the code itself:

<http://www.tfeb.org/programs/lisp/hierarchical-packages.lisp>