From: senator
Subject: Re: uninterned symbols
Date: 
Message-ID: <1145235267.471338.207310@i39g2000cwa.googlegroups.com>
Jeffery Zhang wrote:
> I tried writing the following code
>
> (let ((#:g1 1))
> 	#:g1)
>
> and it gave an error saying that #:g1 has no value. Now I know that #:
> is an uninterned symbol, but how come it works in macros when I use
> (gensym) and generate code that refer to uninterned symbols?

In addition to all the other posts, you might be interested in this
thread, where I got confused over the same issue, and starting
confusing myself even more (the confusion just piled up). Helpful
c.l.l'ers helped set me straight!

http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/d118ad872f845194

Cheers ~~

From: Jeffery Zhang
Subject: Re: uninterned symbols
Date: 
Message-ID: <e21eqf$s25$1@ruby.cit.cornell.edu>
So tell me if I'm understanding this right. The code generated by macros 
isn't processed by the reader. So it doesn't call make-symbol multiple 
times which create new symbols each time. Instead the #:g123 in the 
macro expansion from (macroexpand-1) are just pointers to the same symbol.

-Jeff

senator wrote:
> Jeffery Zhang wrote:
> 
>>I tried writing the following code
>>
>>(let ((#:g1 1))
>>	#:g1)
>>
>>and it gave an error saying that #:g1 has no value. Now I know that #:
>>is an uninterned symbol, but how come it works in macros when I use
>>(gensym) and generate code that refer to uninterned symbols?
> 
> 
> In addition to all the other posts, you might be interested in this
> thread, where I got confused over the same issue, and starting
> confusing myself even more (the confusion just piled up). Helpful
> c.l.l'ers helped set me straight!
> 
> http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/d118ad872f845194
> 
> Cheers ~~
> 
From: Pascal Bourguignon
Subject: Re: uninterned symbols
Date: 
Message-ID: <87d5ffn0f2.fsf@thalassa.informatimago.com>
Jeffery Zhang <····@cornell.edu> writes:

> So tell me if I'm understanding this right. The code generated by
> macros isn't processed by the reader. So it doesn't call make-symbol
> multiple times which create new symbols each time. Instead the #:g123
> in the macro expansion from (macroexpand-1) are just pointers to the
> same symbol.

Indeed! :-)  
That's what is nice in lisp, the source is not text, it's s-expressions!

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

WARNING: This product warps space and time in its vicinity.
From: Marco Baringer
Subject: Re: uninterned symbols
Date: 
Message-ID: <m21wvutsxf.fsf@bese.it>
Pascal Bourguignon <···@informatimago.com> writes:

> Jeffery Zhang <····@cornell.edu> writes:
>
>> So tell me if I'm understanding this right. The code generated by
>> macros isn't processed by the reader. So it doesn't call make-symbol
>> multiple times which create new symbols each time. Instead the #:g123
>> in the macro expansion from (macroexpand-1) are just pointers to the
>> same symbol.
>
> Indeed! :-)  
> That's what is nice in lisp, the source is not text, it's s-expressions!

it is infact possible to produce, through macros, un-writeable source
code (code which has no corresponding textual form (custom read macros
aside)). examples:

(defmacro circular-source-code (one-form)
  (let ((body `(progn ,one-form nil)))
    (setf (third body) body)
    body))

(defmacro literal-object-in-source-code (object-type)
  `(class-name (class-of ,(make-instance object-type))))

nb: these are stupid examples and circular-source-code will probably
screw your compiler. i'm just trying to make a (silly) point, not
teach good lisp programming.

-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There is a crack in everything.
That's how the light gets in.
	-Leonard Cohen
From: Barry Margolin
Subject: Re: uninterned symbols
Date: 
Message-ID: <barmar-5E307F.00265219042006@comcast.dca.giganews.com>
In article <··············@bese.it>, Marco Baringer <··@bese.it> wrote:

> Pascal Bourguignon <···@informatimago.com> writes:
> 
> > Jeffery Zhang <····@cornell.edu> writes:
> >
> >> So tell me if I'm understanding this right. The code generated by
> >> macros isn't processed by the reader. So it doesn't call make-symbol
> >> multiple times which create new symbols each time. Instead the #:g123
> >> in the macro expansion from (macroexpand-1) are just pointers to the
> >> same symbol.
> >
> > Indeed! :-)  
> > That's what is nice in lisp, the source is not text, it's s-expressions!
> 
> it is infact possible to produce, through macros, un-writeable source
> code (code which has no corresponding textual form (custom read macros
> aside)). examples:

I think you can actually get the reader to create analogous code using 
#n=/#n# and #. .

> 
> (defmacro circular-source-code (one-form)
>   (let ((body `(progn ,one-form nil)))
>     (setf (third body) body)
>     body))
> 
> (defmacro literal-object-in-source-code (object-type)
>   `(class-name (class-of ,(make-instance object-type))))
> 
> nb: these are stupid examples and circular-source-code will probably
> screw your compiler. i'm just trying to make a (silly) point, not
> teach good lisp programming.

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