From: Ron Garret
Subject: Does anyone use multiple namespaces at the top level?
Date: 
Message-ID: <rNOSPAMon-987345.14283823032008@news.gha.chartermi.net>
It occurred to me that if you set the value of a symbol to itself then 
you can eliminate quotes in certain contexts, which some people 
(particularly Lisp-1 fans) might consider a feature, e.g.:

[1]> (defun foo () 1)
FOO
[2]> (setf foo 'foo)
FOO
[3]> (funcall foo)
1
[4]> (defclass foo () ())
#<STANDARD-CLASS FOO>
[5]> (make-instance foo)
#<FOO #x19FAF5CD>
[6]> 

My question is: does anyone write code where this would cause a 
conflict?  i.e. does anyone write code where a symbol has a function or 
a class binding, and simultaneously a value binding whose value is 
something other than the function or the class or the symbol itself?

rg

From: Tobias C. Rittweiler
Subject: Re: Does anyone use multiple namespaces at the top level?
Date: 
Message-ID: <87eja1ktn8.fsf@freebits.de>
Ron Garret <·········@flownet.com> writes:

> [1]> (defun foo () 1)
> FOO
> [2]> (setf foo 'foo)
> FOO
> [3]> (funcall foo)
>
> ...
>
> My question is: does anyone write code where this would cause a 
> conflict?  i.e. does anyone write code where a symbol has a function or 
> a class binding, and simultaneously a value binding whose value is 
> something other than the function or the class or the symbol itself?

Pretty much all the time; it's most often a _lexical_ binding containing
an _instance_ of some class or structure. (And if you really want to do
something like this, please take inspiration from RPW's DEFLEXICAL.)

  -T.
From: Barry Margolin
Subject: Re: Does anyone use multiple namespaces at the top level?
Date: 
Message-ID: <barmar-C38187.18084523032008@newsgroups.comcast.net>
In article <··············@freebits.de>,
 "Tobias C. Rittweiler" <···@freebits.de.invalid> wrote:

> Ron Garret <·········@flownet.com> writes:
> 
> > [1]> (defun foo () 1)
> > FOO
> > [2]> (setf foo 'foo)
> > FOO
> > [3]> (funcall foo)
> >
> > ...
> >
> > My question is: does anyone write code where this would cause a 
> > conflict?  i.e. does anyone write code where a symbol has a function or 
> > a class binding, and simultaneously a value binding whose value is 
> > something other than the function or the class or the symbol itself?
> 
> Pretty much all the time; it's most often a _lexical_ binding containing
> an _instance_ of some class or structure. (And if you really want to do
> something like this, please take inspiration from RPW's DEFLEXICAL.)

Also common is something like this:

(defun do-something-to-list (list)
  ...)

And an automotive application might use variables named CAR.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Ron Garret
Subject: Re: Does anyone use multiple namespaces at the top level?
Date: 
Message-ID: <rNOSPAMon-2B39EF.15481323032008@news.gha.chartermi.net>
In article <····························@newsgroups.comcast.net>,
 Barry Margolin <······@alum.mit.edu> wrote:

> In article <··············@freebits.de>,
>  "Tobias C. Rittweiler" <···@freebits.de.invalid> wrote:
> 
> > Ron Garret <·········@flownet.com> writes:
> > 
> > > [1]> (defun foo () 1)
> > > FOO
> > > [2]> (setf foo 'foo)
> > > FOO
> > > [3]> (funcall foo)
> > >
> > > ...
> > >
> > > My question is: does anyone write code where this would cause a 
> > > conflict?  i.e. does anyone write code where a symbol has a function or 
> > > a class binding, and simultaneously a value binding whose value is 
> > > something other than the function or the class or the symbol itself?
> > 
> > Pretty much all the time; it's most often a _lexical_ binding containing
> > an _instance_ of some class or structure. (And if you really want to do
> > something like this, please take inspiration from RPW's DEFLEXICAL.)
> 
> Also common is something like this:
> 
> (defun do-something-to-list (list)
>   ...)
> 
> And an automotive application might use variables named CAR.

Yes, this use-case I am aware of.  This is why I specifically asked only 
about top-level bindings.

rg
From: Barry Margolin
Subject: Re: Does anyone use multiple namespaces at the top level?
Date: 
Message-ID: <barmar-7E780C.20570424032008@newsgroups.comcast.net>
In article <·······························@news.gha.chartermi.net>,
 Ron Garret <·········@flownet.com> wrote:

> In article <····························@newsgroups.comcast.net>,
>  Barry Margolin <······@alum.mit.edu> wrote:
> 
> > In article <··············@freebits.de>,
> >  "Tobias C. Rittweiler" <···@freebits.de.invalid> wrote:
> > 
> > > Ron Garret <·········@flownet.com> writes:
> > > 
> > > > [1]> (defun foo () 1)
> > > > FOO
> > > > [2]> (setf foo 'foo)
> > > > FOO
> > > > [3]> (funcall foo)
> > > >
> > > > ...
> > > >
> > > > My question is: does anyone write code where this would cause a 
> > > > conflict?  i.e. does anyone write code where a symbol has a function or 
> > > > a class binding, and simultaneously a value binding whose value is 
> > > > something other than the function or the class or the symbol itself?
> > > 
> > > Pretty much all the time; it's most often a _lexical_ binding containing
> > > an _instance_ of some class or structure. (And if you really want to do
> > > something like this, please take inspiration from RPW's DEFLEXICAL.)
> > 
> > Also common is something like this:
> > 
> > (defun do-something-to-list (list)
> >   ...)
> > 
> > And an automotive application might use variables named CAR.
> 
> Yes, this use-case I am aware of.  This is why I specifically asked only 
> about top-level bindings.

The problem is that if you do a toplevel DEFVAR, it impacts these uses.  
Because DEFVAR globally proclaims the variable special, so these become 
dynamic bindings rather than lexical bindings.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE don't copy me on replies, I'll read them in the group ***