From: Christian Pohlmann
Subject: TYPEP
Date: 
Message-ID: <b7tnu6$lqp$1@ulric.tng.de>
Hello,

there's something confusing me about TYPEP.

I've read in some book examples like

(TYPEP 7 NUMBER)

or

(TYPEP 'X SYMBOL)

Entering these forms results in an error.

But if I add a ' before "NUMBER" or "SYMBOL", the form is evaluated. Why?

Kindest regards,

C. Pohlmann

From: Franz Kafka
Subject: Re: TYPEP
Date: 
Message-ID: <b3b6b110.0304200819.580c69dc@posting.google.com>
Christian Pohlmann <·················@ki.tng.de> wrote in message news:<············@ulric.tng.de>...
> Hello,
> 
> there's something confusing me about TYPEP.
> 
> I've read in some book examples like
> 
> (TYPEP 7 NUMBER)
> 
> or
> 
> (TYPEP 'X SYMBOL)
> 
> Entering these forms results in an error.
> 
> But if I add a ' before "NUMBER" or "SYMBOL", the form is evaluated. Why?
> 
> Kindest regards,
> 
> C. Pohlmann


Type:

(TYPEP 7 'NUMBER)

or

(TYPEP 'X 'SYMBOL)

If you forget to type 'SYMBOL and type SYMBOL instead the compiler
will
think that SYMBOL is a var. and will generate an error because SYMBOL
prob.
is unbound or not the arg. that TYPEP expects.

'SYMBOL is equiv. to (quote symbol) so you could type

(TYPEP 7 (QUOTE NUMBER))

or

(TYPEP (QUOTE X) (QUOTE SYMBOL))

Lisp used 'X inplace of (QUOTE X) because 'X is easier to type and
less confusing to programmers. The QUOTE function tells Lisp not to
evaluate
the expression.
From: Steven M. Haflich
Subject: Re: TYPEP
Date: 
Message-ID: <3EA34028.10403@alum.mit.edu>
Franz Kafka wrote:
> ...
> If you forget to type 'SYMBOL and type SYMBOL instead the compiler will
> think that SYMBOL is a var. and will generate an error
 > ...

Why must you drag the compiler into this explanation?  The original issue
revolves around a basic beginner's confusion about evaluation semantics
It is elegantly explained elsewhere in this thread by pointing out that
TYPEP is a function, and argument subforms in a function call are
evaluated before the function is called.  Compilation and the compiler
have nothing to do with this basic fact of language semantics.

Most beginners need this notion of functions and argument subform
evaluation explained several times in several different contexts before
they fully get it.  It feels like magic to beginners, whereas we all
have learned that basic evaluation semantics depend on only a few simple
and fairly regular rules.  Later on, the beginner needs to understand
fnuction and file compilation, which again, seems like incomprehensible
magic.  That muddle is indeed more complex that basic evaluation, but
eventually it is understandable.  It is counterproductive to drag
compilation into the explanation ahead of time, before it is relevant.
From: Ivan Boldyrev
Subject: Re: TYPEP
Date: 
Message-ID: <dlbanx7ju.ln2@elaleph.borges.cgitftp.uiggm.nsc.ru>
On 8354 day of my life Christian Pohlmann wrote:
> Hello,
> 
> there's something confusing me about TYPEP.
> 
> I've read in some book examples like
> 
> (TYPEP 7 NUMBER)
> 
> or
> 
> (TYPEP 'X SYMBOL)
> 
> Entering these forms results in an error.
> 
> But if I add a ' before "NUMBER" or "SYMBOL", the form is evaluated. Why?

I think these book are wrong ones.  :) TYPEP is a function, and every
argument is evaluated.

Interesting, how many people will reply Christian's post?  I think,
above 10 of them :)

-- 
Ivan Boldyrev
PGP fp: 3640 E637 EE3D AA51 A59F  3306 A5BD D198 5609 8673   ID 56098673

                       Perl is a language where 2 x 2 is not equal to 4.
From: Coby Beck
Subject: Re: TYPEP
Date: 
Message-ID: <b7u6ei$2em6$1@otis.netspace.net.au>
"Christian Pohlmann" <·················@ki.tng.de> wrote in message
·················@ulric.tng.de...
> Hello,
>
> there's something confusing me about TYPEP.
>
> I've read in some book examples like
>
> (TYPEP 7 NUMBER)
>
> or
>
> (TYPEP 'X SYMBOL)
>
> Entering these forms results in an error.
>
> But if I add a ' before "NUMBER" or "SYMBOL", the form is evaluated. Why?

observe:

CL-USER 4 > (setf number 'symbol)
SYMBOL

CL-USER 5 > (typep 7 number)
NIL

CL-USER 6 > (typep 'huh? number)
T

CL-USER 7 > (describe 'typep)

TYPEP is a SYMBOL
NAME          "TYPEP"
VALUE         #<unbound value>
FUNCTION      #<function TYPEP 201B2472>
PLIST         (PKG::SYMBOL-NAME-STRING "TYPEP" COMPILER::PC-TRANSFORMS
COMPILER::TYPEP-TRANSFORM COMPILER::%PC-P2-TRANSFORMS
COMPILER::TYPEP-P2-TRANSFORM)
PACKAGE       #<PACKAGE COMMON-LISP>

typep is a function, its arguments will be evaluated, your book should have
a quote in front of arguments that are not meant to be evaluated.

 HTH

--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")