From: Schüle Daniel
Subject: '() not the same as (list) ?
Date: 
Message-ID: <er51ia$80e$1@news2.rz.uni-karlsruhe.de>
hello,

Break 15 [19]> (eval (append (list (first '(+ *))) '(1 2 3)))
6

why not
Break 14 [18]> (eval (append (list (first (list + *))) '(1 2 3)))

when this holds true
Break 15 [19]> (equal '(1 2 3) (list 1 2 3))
T

I thought that '() is the same as (list)
what is the difference here?

Regards, Daniel

From: Kaz Kylheku
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <1171656210.550012.45500@j27g2000cwj.googlegroups.com>
On Feb 16, 2:44 am, Sch�le Daniel <····@rz.uni-karlsruhe.de> wrote:
> hello,
>
> Break 15 [19]> (eval (append (list (first '(+ *))) '(1 2 3)))
> 6
>
> why not
> Break 14 [18]> (eval (append (list (first (list + *))) '(1 2 3)))
>
> when this holds true
> Break 15 [19]> (equal '(1 2 3) (list 1 2 3))
> T
>
> I thought that '() is the same as (list)
> what is the difference here?

I don't see any '() or (list) in your example. The two are different.
The first one is a notation which means the same thing as (QUOTE NIL)
and the other is (LIST). They are two different structures. When they
are evaluated as expressions, they both yield the value NIL, so they
are equivalent under evaluation.  Another expression which yields NIL
is, for instance, (STRINGP 1), since 1 is not a string. So (STRINGP 1)
is also equivalent to (LIST), under evaluation.

(LIST + *) is definitely not the same under evaluation as '(+ *),
because (LIST + *) evaluates the symbols + and * as variables, whereas
they represent themselves in '(+ *). For instance

  (let ((+ 1) (* 2))
    (list + *))

produces

  (1 2)

It is (LIST '+ '*) that will produce a list that is EQUAL to '(+ *).

Conversely, the backquote `(,+ ,*) behaves like (LIST + *). The comma
operators request evaluation.
From: Schüle Daniel
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <er80a6$46j$1@news2.rz.uni-karlsruhe.de>
[...]

> (LIST + *) is definitely not the same under evaluation as '(+ *),
> because (LIST + *) evaluates the symbols + and * as variables, whereas
> they represent themselves in '(+ *). For instance
> 
>   (let ((+ 1) (* 2))
>     (list + *))
> 
> produces
> 
>   (1 2)
> 
> It is (LIST '+ '*) that will produce a list that is EQUAL to '(+ *).
> 
> Conversely, the backquote `(,+ ,*) behaves like (LIST + *). The comma
> operators request evaluation.

thank you for your explanation
I didn't know that + and * are variables in some contexts

Regards, Daniel
From: ······@corporate-world.lisp.de
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <1171753289.354729.134650@j27g2000cwj.googlegroups.com>
On Feb 17, 2:41 pm, Schüle Daniel <····@rz.uni-karlsruhe.de> wrote:
> [...]
>
> > (LIST + *) is definitely not the same under evaluation as '(+ *),
> > because (LIST + *) evaluates the symbols + and * as variables, whereas
> > they represent themselves in '(+ *). For instance
>
> >   (let ((+ 1) (* 2))
> >     (list + *))
>
> > produces
>
> >   (1 2)
>
> > It is (LIST '+ '*) that will produce a list that is EQUAL to '(+ *).
>
> > Conversely, the backquote `(,+ ,*) behaves like (LIST + *). The comma
> > operators request evaluation.
>
> thank you for your explanation
> I didn't know that + and * are variables in some contexts

They are defined in the Common Lisp standard to be global variables:

*, **, ***  http://www.lisp.org/HyperSpec/Body/var_stcm_ststcm_ststst.html
+, ++, +++  http://www.lisp.org/HyperSpec/Body/var_plcm_plplcm_plplpl.html
/, //, ///  http://www.lisp.org/HyperSpec/Body/var_slcm_slslcm_slslsl.html
-           http://www.lisp.org/HyperSpec/Body/var_-.html


>
> Regards, Daniel
From: Pascal Bourguignon
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <87fy949w01.fsf@thalassa.informatimago.com>
Sch�le Daniel <····@rz.uni-karlsruhe.de> writes:

> [...]
>
>> (LIST + *) is definitely not the same under evaluation as '(+ *),
>> because (LIST + *) evaluates the symbols + and * as variables, whereas
>> they represent themselves in '(+ *). For instance
>>
>>   (let ((+ 1) (* 2))
>>     (list + *))
>>
>> produces
>>
>>   (1 2)
>>
>> It is (LIST '+ '*) that will produce a list that is EQUAL to '(+ *).
>>
>> Conversely, the backquote `(,+ ,*) behaves like (LIST + *). The comma
>> operators request evaluation.
>
> thank you for your explanation
> I didn't know that + and * are variables in some contexts

But even if + and * weren't defined to be variables, the mere fact of
putting symbols in a value context have them evaluated as variables.

When you evaluate:

  (smurf xyz zorgluf)

smurf is taken to be the name of a function or macro, and
xyz and zorgluf are taken to be the name of variables.

If they're not, you get an error.


The only difference between

         (list 1 2)
and
         (list xyz zorgluf)

is that 1 and 2 are self evaluating: 1 evaluates to 1, and 2 evaluates
to 2, so (list 1 2) evaluates to a list like (1 2), 
while xyz and zorgluf evaluate as the value these variables are bound
to, if any (or an error otherwise).

On the other hand, with quote, there's no evaluation involved:

     (quote (1 2))         evaluates to the (1 2) that is inside the
                           quote form,

and  (quote (xyz zorgluf)) evalutes to the (xyz zorgluf) that is
                           inside the quote form.

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

READ THIS BEFORE OPENING PACKAGE: According to certain suggested
versions of the Grand Unified Theory, the primary particles
constituting this product may decay to nothingness within the next
four hundred million years.
From: Nils M Holm
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <er52qt$cgu$1@online.de>
Schüle Daniel <····@rz.uni-karlsruhe.de> wrote:
> Break 15 [19]> (eval (append (list (first '(+ *))) '(1 2 3)))
> 6
> 
> why not
> Break 14 [18]> (eval (append (list (first (list + *))) '(1 2 3)))
> 
> when this holds true
> Break 15 [19]> (equal '(1 2 3) (list 1 2 3))
> T
> 
> I thought that '() is the same as (list)
> what is the difference here?

'() is the same as (list), but '(+ *) is not the same as (list + *).

-- 
Nils M Holm <n m h @ t 3 x . o r g> -- http://t3x.org/nmh/
From: Pascal Costanza
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <53mgn6F1sg5hpU3@mid.individual.net>
Sch�le Daniel wrote:
> hello,
> 
> Break 15 [19]> (eval (append (list (first '(+ *))) '(1 2 3)))
> 6
> 
> why not
> Break 14 [18]> (eval (append (list (first (list + *))) '(1 2 3)))

You're not quoting + and * here. + and * are predefined variables in 
Common Lisp and do something other than you expect here. Try (list '+ 
'*) instead.


However, what you do here seems very weird. This use of eval is very 
unusual, to say the least, and I don't think you get a lot of useful 
insights by doing what you seem to do here.

What's the background of your experiments here?


Pascal

-- 
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Lars Rune Nøstdal
Subject: Re: '() not the same as (list) ?
Date: 
Message-ID: <pan.2007.02.16.20.29.02.655337@gmail.com>
On Fri, 16 Feb 2007 11:44:11 +0100, Schüle Daniel wrote:

> Break 15 [19]> (eval (append (list (first '(+ *))) '(1 2 3)))

Why do you want to use eval there?

cl-user> (defmacro my-macro ()
           (append (list (first '(+ *))) '(1 2 3)))
my-macro
cl-user> (my-macro)
6
cl-user> (macroexpand-1 '(my-macro))
(+ 1 2 3)
t
cl-user> (defmacro my-macro ()
           (let ((list-of-functions '(+ *))
                 (list-of-arguments '(1 2 3)))
             `(,(first list-of-functions) ,@list-of-arguments)))
             
my-macro
cl-user> (my-macro)
6
cl-user> (macroexpand-1 '(my-macro))
(+ 1 2 3)
t

http://www.gigamonkeys.com/book/macros-defining-your-own.html

-- 
Lars Rune Nøstdal
http://nostdal.org/