From: André Thieme
Subject: How to make a string out of a symbol?
Date: 
Message-ID: <ccfen0$503$1@ulric.tng.de>
I can do

CL-USER 1 > (string 'foo)
"FOO"

If creating a string out of a symbol is the only thing I want my 
function to do, how then would I implement the function my-string?


Andr�
--

From: Paul F. Dietz
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <UKydnVqR0u0K3XbdRVn-ig@dls.net>
Andr� Thieme wrote:
> I can do
> 
> CL-USER 1 > (string 'foo)
> "FOO"
> 
> If creating a string out of a symbol is the only thing I want my 
> function to do, how then would I implement the function my-string?

See the builtin function SYMBOL-NAME.

	Paul
From: Carl Shapiro
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ouy3c44qsi7.fsf@panix3.panix.com>
"Paul F. Dietz" <·····@dls.net> writes:

> Andr� Thieme wrote:
> > I can do
> > CL-USER 1 > (string 'foo)
> > "FOO"
> > If creating a string out of a symbol is the only thing I want my
> > function to do, how then would I implement the function my-string?
> 
> See the builtin function SYMBOL-NAME.

I often wonder if this is the right answer to the "how do I coerce a
symbol into a string" question.  In every implementation I have used,
SYMBOL-NAME will return the system's string for a symbol.  But, that
string doesn't belong to you and you shouldn't ever touch it!  For
better or worse, this behavior is prefectly legal; the standard states
that the consequences are undefined if you modify the returned string.
So, if you don't know what will happen to the string returned from
SYMBOL-NAME, it would be wise to perform the coercion like so:

  (defun symbol-to-string (symbol) (copy-seq (symbol-name symbol))
From: Pascal Bourguignon
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <87brisb93h.fsf@thalassa.informatimago.com>
Carl Shapiro <·············@panix.com> writes:

> "Paul F. Dietz" <·····@dls.net> writes:
> 
> > Andr� Thieme wrote:
> > > I can do
> > > CL-USER 1 > (string 'foo)
> > > "FOO"
> > > If creating a string out of a symbol is the only thing I want my
> > > function to do, how then would I implement the function my-string?
> > 
> > See the builtin function SYMBOL-NAME.
> 
> I often wonder if this is the right answer to the "how do I coerce a
> symbol into a string" question.  In every implementation I have used,
> SYMBOL-NAME will return the system's string for a symbol.  But, that
> string doesn't belong to you and you shouldn't ever touch it!  For
> better or worse, this behavior is prefectly legal; the standard states
> that the consequences are undefined if you modify the returned string.
> So, if you don't know what will happen to the string returned from
> SYMBOL-NAME, it would be wise to perform the coercion like so:
> 
>   (defun symbol-to-string (symbol) (copy-seq (symbol-name symbol))

This is endemic in COMMON-LISP.  I don't think that's what Andr�
asked, but that's sure what he should know by his third lesson of
COMMON-LISP...

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

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
From: Tim Bradshaw
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <fbc0f5d1.0407080245.1087452c@posting.google.com>
Carl Shapiro <·············@panix.com> wrote in message news:<···············@panix3.panix.com>...
 
> I often wonder if this is the right answer to the "how do I coerce a
> symbol into a string" question.  In every implementation I have used,
> SYMBOL-NAME will return the system's string for a symbol.  But, that
> string doesn't belong to you and you shouldn't ever touch it!  For
> better or worse, this behavior is prefectly legal; the standard states
> that the consequences are undefined if you modify the returned string.
> So, if you don't know what will happen to the string returned from
> SYMBOL-NAME, it would be wise to perform the coercion like so:
> 
>   (defun symbol-to-string (symbol) (copy-seq (symbol-name symbol))

I don't think that this is really anything you can avoid if you're
using a language which allows you to mutate objects.  You need some
kind of `ownership protocol' for objects, and not just system objects.
 Whenever you have an accessor which returns something which might
represent part of the internal state of some object, then there's a
conflict between returning the actual internal state and doing some
kind of copy.  Copying means, well, copying, returning (or possibly
returning) the internal state itself means your callers have to be
careful.

--tim
From: Carl Shapiro
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ouyr7rku7bw.fsf@panix3.panix.com>
··········@tfeb.org (Tim Bradshaw) writes:

> I don't think that this is really anything you can avoid if you're
> using a language which allows you to mutate objects.  You need some
> kind of `ownership protocol' for objects, and not just system objects.

Both packages and symbols are fundamental strucutres in Lisp.  Alas,
the specifications for INTERN, MAKE-SYMBOL, and SYMBOL-NAME leave
critical details up to the implementor to resolve.  While that grants
a huge optimization opportunity for implentors it is done at a great
expense to users.

Elsewhere in Lisp, as is the case with non-immediate numerical types,
implementations ensure that a lot of copying occurs to maintain the
integrity of shared structure.  There is an obvious performance
trade-off here, I just wish the standard was more explicit about what
I can reasonably expect and what I cannot.  In the case of symbols,
not knowing when the system is going to co-opt structure forces the
cautious user to do a lot of questionable copying.
From: Christopher C. Stacy
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <usmc07o88.fsf@news.dtpq.com>
>>>>> On 09 Jul 2004 18:46:59 -0400, Carl Shapiro ("Carl") writes:

 Carl> ··········@tfeb.org (Tim Bradshaw) writes:
 >> I don't think that this is really anything you can avoid if you're
 >> using a language which allows you to mutate objects.  You need some
 >> kind of `ownership protocol' for objects, and not just system objects.

 Carl> Both packages and symbols are fundamental strucutres in Lisp.  Alas,
 Carl> the specifications for INTERN, MAKE-SYMBOL, and SYMBOL-NAME leave
 Carl> critical details up to the implementor to resolve.  While that grants
 Carl> a huge optimization opportunity for implentors it is done at a great
 Carl> expense to users.

 Carl> Elsewhere in Lisp, as is the case with non-immediate numerical types,
 Carl> implementations ensure that a lot of copying occurs to maintain the
 Carl> integrity of shared structure.  There is an obvious performance
 Carl> trade-off here, I just wish the standard was more explicit about what
 Carl> I can reasonably expect and what I cannot.  In the case of symbols,
 Carl> not knowing when the system is going to co-opt structure forces the
 Carl> cautious user to do a lot of questionable copying.

I thought there was never any question that the value of SYMBOL-NAME
is read-only.  What is this "great cost" you speak of?
From: Carl Shapiro
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ouysmc0owr8.fsf@panix3.panix.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

> I thought there was never any question that the value of SYMBOL-NAME
> is read-only.  What is this "great cost" you speak of?

The great expense is that users are forced to manually manage the
symbol print name strings passed to INTERN and MAKE-SYMBOL, and those
returned from SYMBOL-NAME.  In almost all implementations I have used
INTERN and MAKE-SYMBOL copy the print name strings before interning
them, and SYMBOL-NAME returns that copied string.  However, the
standard makes no guarantees that this will be the case.
From: Christopher C. Stacy
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <uhdsdtean.fsf@news.dtpq.com>
>>>>> On 10 Jul 2004 08:46:35 -0400, Carl Shapiro ("Carl") writes:

 Carl> ······@news.dtpq.com (Christopher C. Stacy) writes:
 >> I thought there was never any question that the value of SYMBOL-NAME
 >> is read-only.  What is this "great cost" you speak of?

 Carl> The great expense is that users are forced to manually manage the
 Carl> symbol print name strings passed to INTERN and MAKE-SYMBOL, and those
 Carl> returned from SYMBOL-NAME.  In almost all implementations I have used
 Carl> INTERN and MAKE-SYMBOL copy the print name strings before interning
 Carl> them, and SYMBOL-NAME returns that copied string.  However, the
 Carl> standard makes no guarantees that this will be the case.

I always thought that the string you give intern is your own string 
that you can do what you want, and SYMBOL-NAME is a string that belongs
to the system which you're not allowed to copy.  That's just based on
assumptions from the cultural experience where I come from, though.  
I never read that part of the standard to see if it was true in CL.

If you treat them that way, the only one to worry about is the 
string you are passing to INTERN.  (Most such strings are being
constructed at macroexpand time, usually compile time, and are
just thrown away anyhow -- I was just interested in the resulting
symbol.  So in practice there's never any worry at all.)

Which implementations behave which way?
From: Peter Seibel
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <m3oeml1ato.fsf@javamonkey.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

>>>>>> On 10 Jul 2004 08:46:35 -0400, Carl Shapiro ("Carl") writes:
>
>  Carl> ······@news.dtpq.com (Christopher C. Stacy) writes:
>  >> I thought there was never any question that the value of SYMBOL-NAME
>  >> is read-only.  What is this "great cost" you speak of?
>
>  Carl> The great expense is that users are forced to manually manage the
>  Carl> symbol print name strings passed to INTERN and MAKE-SYMBOL, and those
>  Carl> returned from SYMBOL-NAME.  In almost all implementations I have used
>  Carl> INTERN and MAKE-SYMBOL copy the print name strings before interning
>  Carl> them, and SYMBOL-NAME returns that copied string.  However, the
>  Carl> standard makes no guarantees that this will be the case.
>
> I always thought that the string you give intern is your own string
> that you can do what you want, and SYMBOL-NAME is a string that
> belongs to the system which you're not allowed to copy. That's just
> based on assumptions from the cultural experience where I come from,
> though. I never read that part of the standard to see if it was true
> in CL.

Nope. In Common Lisp after you hand a string over to INTERN it isn't
necessarily yours any more. From the HyperSpec, INTERN, s.v.:

  It is implementation-dependent whether the string that becomes the
  new symbol's name is the given string or a copy of it. Once a string
  has been given as the string argument to intern in this situation
  where a new symbol is created, the consequences are undefined if a
  subsequent attempt is made to alter that string.

-Peter

-- 
Peter Seibel                                      ·····@javamonkey.com

         Lisp is the red pill. -- John Fraser, comp.lang.lisp
From: Carl Shapiro
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ouypt71vv3s.fsf@panix3.panix.com>
······@news.dtpq.com (Christopher C. Stacy) writes:

> I always thought that the string you give intern is your own string 
> that you can do what you want, and SYMBOL-NAME is a string that belongs
> to the system which you're not allowed to copy.  

(Are you sure you wanted to say "not allowed to copy"?  That seems
like a typo.)

                                                   That's just based on
> assumptions from the cultural experience where I come from, though.  
> I never read that part of the standard to see if it was true in CL.

Well, the Lisp Machine would copy the print name string passed to
MAKE-SYMBOL only when MAKE-SYMBOL was called with the optional
PERMANENT-P argument set to true.  Mind you this was not the default
behavior.  When PERMANENT-P was set, a fresh string was allocated from
the print name area and filled with the contents of the user's print
name.  The PERMANENT-P argument also effected the area where the
result of %MAKE-STRUCTURE was CONSed into, the default being the
working storage area.

INTERN always called MAKE-SYMBOL with the PERMANENT-P flag set to
true on every LispM I know of.

SYMBOL-NAME (and GET-PNAME before it) returns the print name string
belonging to the symbol structure.

> If you treat them that way, the only one to worry about is the 
> string you are passing to INTERN.  (Most such strings are being
> constructed at macroexpand time, usually compile time, and are
> just thrown away anyhow -- I was just interested in the resulting
> symbol.  So in practice there's never any worry at all.)

The situation I have in mind is one where you are reading strings off
disk into an in-memory buffer or a resourced string, which you later
plan on using as an argument to INTERN.  If you obey the letter of the
standard, you cannot just INTERN those strings straight-away without
first copying them.  That is a huge performance loser as you will end
up allocating at least twice as many strings as need be.  That ratio
can get a whole lot worse if you are performing some sort of parsing
operation where you use INTERN to sometimes create and sometimes find
already created symbols.

(The amount of worrying you need to do is clearly a function of what
you are using INTERN for.)
From: Rob Warnock
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <XaydnbgB98l6j27dRVn-sw@speakeasy.net>
Christopher C. Stacy <······@news.dtpq.com> wrote:
+---------------
| I always thought that the string you give intern is your own string 
| that you can do what you want, and SYMBOL-NAME is a string that belongs
| to the system which you're not allowed to copy.
+---------------

Of *course* you're allowed to *copy* it; what you're not allowed to
do it modify it. (And copying is how you avoid that.)


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Christopher C. Stacy
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <upt70e775.fsf@news.dtpq.com>
>>>>> On Mon, 12 Jul 2004 17:38:31 -0500, Rob Warnock ("Rob") writes:

 Rob> Christopher C. Stacy <······@news.dtpq.com> wrote:
 Rob> +---------------
 Rob> | I always thought that the string you give intern is your own string 
 Rob> | that you can do what you want, and SYMBOL-NAME is a string that belongs
 Rob> | to the system which you're not allowed to copy.
 Rob> +---------------

 Rob> Of *course* you're allowed to *copy* it; what you're not allowed
 Rob> to do it modify it. (And copying is how you avoid that.)

As someone else noticed, I was thinking "want to munge, must make 
a copy", but only the word "copy" made it down to the fingers.

Mmmmmm... p-names.
From: André Thieme
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ccffls$5k5$2@ulric.tng.de>
Paul F. Dietz schrieb:

> Andr� Thieme wrote:
> 
>> I can do
>>
>> CL-USER 1 > (string 'foo)
>> "FOO"
>>
>> If creating a string out of a symbol is the only thing I want my 
>> function to do, how then would I implement the function my-string?
> 
> 
> See the builtin function SYMBOL-NAME.

And how does SYMBOL-NAME implement this functionality?


Andr�
--
From: Paul F. Dietz
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <FKydnWXeq8-I2HbdRVn-hA@dls.net>
Andr� Thieme wrote:

> And how does SYMBOL-NAME implement this functionality?

It's a builtin function.  It's not implemented in terms
of other lisp operators, it's a primitive.

Are you asking how a lisp implementation would implement this
primitive function?

	Paul
From: André Thieme
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ccfgr7$6pj$1@ulric.tng.de>
Paul F. Dietz schrieb:
> Andr� Thieme wrote:
> 
>> And how does SYMBOL-NAME implement this functionality?
> 
> 
> It's a builtin function.  It's not implemented in terms
> of other lisp operators, it's a primitive.
> 
> Are you asking how a lisp implementation would implement this
> primitive function?

I was thinking about statements from Wikipedia:
http://en.wikipedia.org/wiki/Lisp_programming_language

Especially this interests me:
http://en.wikipedia.org/wiki/Lisp_programming_language#Minimal_Lisp


This means with seven "functions" (first, rest, cons, quote, eq, if, 
lambda) I can build a lisp. If I only have these, what would be the 
strategy to implement the functionality of SYMBOL-NAME?


Andr�
--
From: Christopher C. Stacy
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ubrisobk2.fsf@news.dtpq.com>
>>>>> On Wed, 07 Jul 2004 02:41:51 +0200, Andr� Thieme ("Andr�") writes:

 Andr�> This means with seven "functions" (first, rest, cons, quote, eq, if,
 Andr�> lambda) I can build a lisp. If I only have these, what would be the
 Andr�> strategy to implement the functionality of SYMBOL-NAME?

 Andr�> I was thinking about statements from Wikipedia

As one would expect, the Wikipedia is not a reliable 
source for good information.  Someone there has invented
their own definition of what "Lisp" is, and it does not
relate to Common Lisp.
From: Karl A. Krueger
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ccfn69$8kc$1@baldur.whoi.edu>
Andr? Thieme <······························@justmail.de> wrote:
> I was thinking about statements from Wikipedia:
> http://en.wikipedia.org/wiki/Lisp_programming_language

This article discusses "Lisp languages" in general, and does not refer
to Common Lisp.  Try the "Common Lisp" article for more detail on the
flavor of Lisp you are using.


> This means with seven "functions" (first, rest, cons, quote, eq, if, 
> lambda) I can build a lisp. If I only have these, what would be the 
> strategy to implement the functionality of SYMBOL-NAME?

How would you implement C's "printf" using Turing machine operations?

(If you are interested in how a Lisp system can be built on top of a
simpler or different one, Christian Queinnec's _Lisp In Small Pieces_
discusses just that.  I'd give more detail but I'm only about a third of
the way through it and my copy is at work.)

-- 
Karl A. Krueger <········@example.edu>
Woods Hole Oceanographic Institution
Email address is spamtrapped.  s/example/whoi/
"Outlook not so good." -- Magic 8-Ball Software Reviews
From: Pascal Bourguignon
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <87fz84bg8u.fsf@thalassa.informatimago.com>
Andr� Thieme <······························@justmail.de> writes:

> Paul F. Dietz schrieb:
> > Andr� Thieme wrote:
> >
> >> And how does SYMBOL-NAME implement this functionality?
> > It's a builtin function.  It's not implemented in terms
> > of other lisp operators, it's a primitive.
> > Are you asking how a lisp implementation would implement this
> > primitive function?
> 
> I was thinking about statements from Wikipedia:
> http://en.wikipedia.org/wiki/Lisp_programming_language
> 
> Especially this interests me:
> http://en.wikipedia.org/wiki/Lisp_programming_language#Minimal_Lisp
> 
> 
> This means with seven "functions" (first, rest, cons, quote, eq, if,
> lambda) I can build a lisp. If I only have these, what would be the
> strategy to implement the functionality of SYMBOL-NAME?


Or ask yourself what would be your strategy to implement INTERN  or
READ!  Note that there are no I/O amongst these seven fundamental
functions...

To get an idea of the practical problem (but an hint of the theoretical
"beauty"):

<sorry, lots of silly code follows...>

(defun 0 () (quote ()))
(defun 1 () (cons (quote ()) 0))
(defun 2 () (cons (quote ()) 1))
(defun 3 () (cons (quote ()) 3))
;; ...

(defun + (a b) (if (eq (0) a) b (+ (cdr a) (cons (quote ()) b))))
(defun * (a b) (if (eq (0) a) (0) (if (eq (1) a) b (+ b (* (cdr a) b)))))
;; ...


Now, to encode characters, you could do as in emacs, where the
character type is the same as fixnum, and to encode strings you'd just
use lists of numbers. So "ABC" would be (in ASCII):

((() () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () ())
 (() () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () ())
 (() () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () ()))

But you'd rather have typed values.  So let's say that you tag the
values in the following way:

(defun make-integer (value) (cons (quote (())) value))
(defun make-char    (value) (cons (quote (()())) value))
(defun make-string  (value) (cons (quote (()()())) value))
(defun make-cons    (value) 
    "That would be a COMMON-LISP cons, not a primitive cons!"
    (cons (quote (()()()())) value))
;; ...
(defun get-value (tagged-value) (cdr tagged-value))
(defun get-tag   (tagged-value) (car tagged-value))
(defun integerp (tagged-value) (eq (get-tag (make-integer nil))
                                   (get-tag tagged-value)))
(defun charp    (tagged-value) (eq (get-tag (make-char nil))
                                   (get-tag tagged-value)))
(defun stringp  (tagged-value) (eq (get-tag (make-string nil))
                                   (get-tag tagged-value)))
(defun consp    (tagged-value) (eq (get-tag (make-cons nil))
                                   (get-tag tagged-value)))


Then to make COMMON-LISP number you'd have to add calls to
make-integer, get-tag and get-value in the above constant number and
operation functions.


Now of course you can't do real I/O with these primitives, but you can
imagine how you could write an emulator to do it, and implement a whole 
imaginary Common-Lisp over them.

For example, once you have a string type as defined above, you could
implement files as mere named strings and a file system as a list of
named strings.

(defun file-system ()
  "Return a file system composed of two files, 
     one named 'A' containing '012' and the
     other named 'B' containing 'ABC'"
  (quote (((() () () () () () () () () () () () () () () () () () ()
            () () () () () () () () () () () () () () () () () () ()
            () () () () () () () () () () () () () () () () () () ()
            () () () () () () () ())
           ((() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () ())
            (() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () ())
            (() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () ())))
          ((() () () () () () () () () () () () () () () () () () ()
            () () () () () () () () () () () () () () () () () () ()
            () () () () () () () () () () () () () () () () () () ()
            () () () () () () () () ())
           ((() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () ())
            (() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () ())
            (() () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () () () () () () () () () () ()
             () () () () () () () () () ()))))))

So, now you could implement a COMMON-LISP:OPEN function, and a
READ-CHAR function, and a READ-STRING, so the question of how you'd
get a string to feed INTERN is imaginarily solved.

Of course, INTERN would not create a symbol such as these primitive
car cdr cons quote et if and defun!  INTERN would create a
"COMMON-LISP" symbol with this function:

(defun make-symbol (value)    (cons (quote (()()()()())) value))
(defun symbolp (tagged-value) (eq (get-tag (make-symbol nil))
                                  (get-tag tagged-value)))


So now, your INTERN could look like:

(defun intern (name)
    (if (stringp name)
      (put-in-symbol-table
        (make-symbol
          (cons name ;; symbol-name
            (cons nil ;; no symbol-value (not (boundp))
              (cons nil ;; no symbol-function (not (fboundp))
                (cons nil ;; no symbol-package for now...
                      nil)))))))) ;; empty symbol-plist
                    

So now, of course an implementation of SYMBOL-NAME would be:

(defun symbol-name (symbol)
    (if (symbolp symbol)
      (car (get-value symbol))))

For example, to get the name of the symbol named "ABC", you would call:

(symbol-name (quote ((() () () () ()) ((() () ()) (() () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () ()) (() () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () ()) (() () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () ())) () () ())))

and of course, the result would be:

((() () ()) (() () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ()
 () () () () () () () () () () () () () () () () () () () () () () ())
 (() () () () () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () () ()) (() () ()
  () () () () () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () () () () () () ()
  () () () () () () () () () () () () () () () () () ()))

ie. the string "ABC"!


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

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
From: =?ISO-8859-15?Q?Andr=E9_Thieme?=
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ccgq02$dd4$1@ulric.tng.de>
Wow, great explanations, thanks! I now got the idea.


Andr�
--
From: Tim Bradshaw
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ey3k6xgw88c.fsf@cley.com>
* Andr  wrote:
> This means with seven "functions" (first, rest, cons, quote, eq, if,
> lambda) I can build a lisp. If I only have these, what would be the
> strategy to implement the functionality of SYMBOL-NAME?

Well, consider a more interesting question: how would you implement
WITH-OPEN-FILE?

--tim
From: Pascal Costanza
Subject: Re: How to make a string out of a symbol?
Date: 
Message-ID: <ccgnmu$14jc$1@f1node01.rhrz.uni-bonn.de>
Andr� Thieme wrote:

> And how does SYMBOL-NAME implement this functionality?

You can roughly understand the SYMBOL as a structure type as follows:

(defstruct symbol
   package name value function plist)

Structures are similar to structs in C, records in Pascal, or classes in 
most object-oriented languages. (This is not the complete picture, 
because the "fields" of a symbol all behave in special ways that are 
hard to implement on your own.)


Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)