From: Zehao Chen
Subject: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9g8fp$i33$1@mail.cn99.com>
Hello, everyone, I have a little question on the bool function.

When I run
 > (evenp 'a)
there is nothing returned, neither t nor nil.

and I when I type the following statement:
 > (if (evenp 'a) 1 0)

the system displays nothing, neither 1 or 0.

I am curious about this feature of LISP.

Thank you!

From: Matthew Danish
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <20030509095659.B22493@mapcar.org>
On Fri, May 09, 2003 at 08:55:06PM +0800, Zehao Chen wrote:
> Hello, everyone, I have a little question on the bool function.
> 
> When I run
>  > (evenp 'a)
> there is nothing returned, neither t nor nil.
> 
> and I when I type the following statement:
>  > (if (evenp 'a) 1 0)
> 
> the system displays nothing, neither 1 or 0.
> 
> I am curious about this feature of LISP.
> 

Which implementation are you using?  Is it a Common Lisp implementation?

If it is, try (proclaim '(optimize (safety 3))) and then type (evenp 'a) again.
If it does not signal a type-error, then it has a bug.  (This bug might be that
it lacks a debugger or any such facilities, though).

-- 
; Matthew Danish <·······@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
From: Franz Kafka
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <BGNua.5635$C92.5301@news02.roc.ny.frontiernet.net>
"Zehao Chen" <··········@hotmail.com> wrote in message
·················@mail.cn99.com...
> Hello, everyone, I have a little question on the bool function.
>
> When I run
>  > (evenp 'a)
> there is nothing returned, neither t nor nil.
>
> and I when I type the following statement:
>  > (if (evenp 'a) 1 0)
>
> the system displays nothing, neither 1 or 0.
>
> I am curious about this feature of LISP.
>
> Thank you!
>

It could also signal an error that evenp expects a
number how can the symbol 'a be even.

(evenp 2) returns t
(evenp 1) returns nil

Only numbers can be even or odd.

Your Lisp might expect 'a to be a var .that holds a number--when
this is not true Lisp can do anything from returning no value to
crashing the system.

Also try

(ignore-errors (evenp 'a)) ;; ;)
From: Zehao Chen
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9gb3u$kdg$1@mail.cn99.com>
(ignore-errors (evenp 'a)) sounds work!
Thanks!!:)

Franz Kafka wrote:
> "Zehao Chen" <··········@hotmail.com> wrote in message
> ·················@mail.cn99.com...
> 
>>Hello, everyone, I have a little question on the bool function.
>>
>>When I run
>> > (evenp 'a)
>>there is nothing returned, neither t nor nil.
>>
>>and I when I type the following statement:
>> > (if (evenp 'a) 1 0)
>>
>>the system displays nothing, neither 1 or 0.
>>
>>I am curious about this feature of LISP.
>>
>>Thank you!
>>
> 
> 
> It could also signal an error that evenp expects a
> number how can the symbol 'a be even.
> 
> (evenp 2) returns t
> (evenp 1) returns nil
> 
> Only numbers can be even or odd.
> 
> Your Lisp might expect 'a to be a var .that holds a number--when
> this is not true Lisp can do anything from returning no value to
> crashing the system.
> 
> Also try
> 
> (ignore-errors (evenp 'a)) ;; ;)
> 
> 
From: Coby Beck
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9ivs4$24rc$1@otis.netspace.net.au>
"Franz Kafka" <Symbolics _ XL1201 _ Sebek _ Budo _ Kafka @ hotmail . com>
wrote in message ························@news02.roc.ny.frontiernet.net...
>
> "Zehao Chen" <··········@hotmail.com> wrote in message
> ·················@mail.cn99.com...
> > Hello, everyone, I have a little question on the bool function.
> >
> > When I run
> >  > (evenp 'a)
> > there is nothing returned, neither t nor nil.
> >
> > and I when I type the following statement:
> >  > (if (evenp 'a) 1 0)
> >
> > the system displays nothing, neither 1 or 0.
> >
> > I am curious about this feature of LISP.
> >
> > Thank you!
> >
>
> It could also signal an error that evenp expects a
> number how can the symbol 'a be even.

There is no "could" or "would" involved.
In the hyperspec: "Should signal an error of type type-error if integer is
not an integer."

So this is a user error or implementation bug or not a Common Lisp
implementation.

> Your Lisp might expect 'a to be a var .that holds a number

'a is (quote a) which evaluate to a symbol and nothing else.  The
implementation is not free to check if maybe there is a number buried in
there somewhere.

> --when
> this is not true Lisp can do anything from returning no value to
> crashing the system.

Lisp should signal a type-error.  It is not an undefined situation.
Anything else is an implementation bug.
> Alsp try:
>
> (ignore-errors (evenp 'a)) ;; ;)

What on earth for?

-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Matthew Danish
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <20030510105222.D22493@mapcar.org>
On Sat, May 10, 2003 at 11:44:13PM +1000, Coby Beck wrote:
> "Franz Kafka" <Symbolics _ XL1201 _ Sebek _ Budo _ Kafka @ hotmail . com>
> wrote in message ························@news02.roc.ny.frontiernet.net...
> > "Zehao Chen" <··········@hotmail.com> wrote in message
> > ·················@mail.cn99.com...
> > > Hello, everyone, I have a little question on the bool function.  When I
> > > run
> > >  > (evenp 'a)
> > > there is nothing returned, neither t nor nil.  and I when I type the
> > > following statement:
> > >  > (if (evenp 'a) 1 0)
> > > the system displays nothing, neither 1 or 0.  I am curious about this
> > > feature of LISP.  Thank you!
> > It could also signal an error that evenp expects a number how can the
> > symbol 'a be even.
> There is no "could" or "would" involved.  In the hyperspec: "Should signal an
> error of type type-error if integer is not an integer." So this is a user
> error or implementation bug or not a Common Lisp implementation.

Zehao didn't specify whether safety was originally set to 3.  According to the
CLHS, "should signal an error" means in safe code (safety 3).  In other levels,
it is implementation-dependent.  I noticed this too, and got suspicious at the
usage of the word 'should' so I looked it up in the first chapter.

So the behavior of LW here may very well be conforming, depending on the
original (unknown) value of safety.  Unless I've misinterpreted that
definition.

Zehao, in a later message, did report an error was signalled when safety was
set to 3.  I am still a bit curious though, since my copy of LW personal
signals an error for any safety level.

-- 
; Matthew Danish <·······@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
From: Coby Beck
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9k1kp$2deo$1@otis.netspace.net.au>
"Matthew Danish" <·······@andrew.cmu.edu> wrote in message
··························@mapcar.org...
> On Sat, May 10, 2003 at 11:44:13PM +1000, Coby Beck wrote:
> > There is no "could" or "would" involved.  In the hyperspec: "Should
signal an
> > error of type type-error if integer is not an integer." So this is a
user
> > error or implementation bug or not a Common Lisp implementation.
>
> Zehao didn't specify whether safety was originally set to 3.  According to
the
> CLHS, "should signal an error" means in safe code (safety 3).  In other
levels,
> it is implementation-dependent.  I noticed this too, and got suspicious at
the
> usage of the word 'should' so I looked it up in the first chapter.

Thanks for not being as lazy as I was!  I smothered the little voice in my
head that was saying "but it doesn't say 'must'...!"

-- 
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Dave Pearson
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <slrnbbnb8t.3d6.davep.news@hagbard.davep.org>
* Zehao Chen <··········@hotmail.com>:

> When I run
>  > (evenp 'a)
> there is nothing returned, neither t nor nil.

Every implementation of Common Lisp I've got here throws an error when
evaluating that. I'd expect that.

What are you using to test this?

-- 
Dave Pearson
http://www.davep.org/lisp/
From: Zehao Chen
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9gbaa$kmk$1@mail.cn99.com>
It is LispWorks Personal Edition (Xanalys Inc.)
It just displays nothing instead of throwing an error. ^_^

Dave Pearson wrote:
> * Zehao Chen <··········@hotmail.com>:
> 
> 
>>When I run
>> > (evenp 'a)
>>there is nothing returned, neither t nor nil.
> 
> 
> Every implementation of Common Lisp I've got here throws an error when
> evaluating that. I'd expect that.
> 
> What are you using to test this?
> 
From: Nikodemus Siivola
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9gb2f$5ajob$2@midnight.cs.hut.fi>
Zehao Chen <··········@hotmail.com> wrote:
> Hello, everyone, I have a little question on the bool function.

>  > (evenp 'a)
> there is nothing returned, neither t nor nil.

Interesting. Which implementation are you using? Either 

 a) it has an ANSI conformance bug (unlikely)
 b) the error get silently handled inside the read-eval-print loop
    (unlikely unless you've somehow disabled the debugger)
 c) the error messages are being directed somewhere else

Try this:

 > (catch 'err 
       (handler-bind ((error (lambda (e) 
                                (format t "~&Got: '~S'.~%" e) 
                                (throw 'err))))
           (evenp 'a)))

(Double check the parens - I copy-pasted that in a hurry.)

You *should* see something like:

 Got: '#<SIMPLE-TYPE-ERROR {4003BE75}>'.


Cheers,

  -- Nikodemus
From: Matthew Danish
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <20030509095017.A22493@mapcar.org>
On Fri, May 09, 2003 at 01:39:27PM +0000, Nikodemus Siivola wrote:
> Zehao Chen <··········@hotmail.com> wrote:
> > Hello, everyone, I have a little question on the bool function.
> 
> >  > (evenp 'a)
> > there is nothing returned, neither t nor nil.
> 
> Interesting. Which implementation are you using? Either 
> 
>  a) it has an ANSI conformance bug (unlikely)
>  b) the error get silently handled inside the read-eval-print loop
>     (unlikely unless you've somehow disabled the debugger)
>  c) the error messages are being directed somewhere else
> 
> Try this:
> 
>  > (catch 'err 
>        (handler-bind ((error (lambda (e) 
>                                 (format t "~&Got: '~S'.~%" e) 
>                                 (throw 'err))))
>            (evenp 'a)))
> 
> (Double check the parens - I copy-pasted that in a hurry.)
> 
> You *should* see something like:
> 
>  Got: '#<SIMPLE-TYPE-ERROR {4003BE75}>'.

It would be simpler to use:

(handler-case 
    (evenp 'a)
  (error (e) 
    (format t "~&Got: ~S.~%" e)))

here.

-- 
; Matthew Danish <·······@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
From: Nikodemus Siivola
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9h2c8$5bh8o$1@midnight.cs.hut.fi>
Matthew Danish <·······@andrew.cmu.edu> wrote:

...my handler-bind monster deleted...

> It would be simpler to use:
> (handler-case 

Would you believe that I'm learning the condition
system in alphabetical order? ,)=

Thanks,

  -- Nikodemus
From: Zehao Chen
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9gdtr$nnk$1@mail.cn99.com>
Thanks for all.

The LISP I am using is LispWorks Personal Edition.

I have tried
(handler-case
     (evenp 'a)
   (error (e)
     (format t "~&Got: ~S.~%" e)))
and
(proclaim '(optimize (safety 3)))

The system catches a <CONDITIONS:ARITHMETIC-TYPE-ERROR 20667F34>

So it works.





Zehao Chen Wrote:
> Hello, everyone, I have a little question on the bool function.
> 
> When I run
>  > (evenp 'a)
> there is nothing returned, neither t nor nil.
> 
> and I when I type the following statement:
>  > (if (evenp 'a) 1 0)
> 
> the system displays nothing, neither 1 or 0.
> 
> I am curious about this feature of LISP.
> 
> Thank you!
> 
From: Dennis Dunn
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <tVWua.12794$BA.7538019@twister.columbus.rr.com>
Zehao Chen wrote:
> Thanks for all.
> 
<snip>

FWIW, I'm using Lispworks Personal Edition 4.2 on WinXP and this is what 
I get when I type that form in the listener --

CL-USER 1 > (evenp 'a)

Error: In EVENP of (A) arguments should be of type INTEGER.
   1 (continue) Return a value to use.
   2 Supply a new argument.
   3 (abort) Return to level 0.
   4 Return to top loop level 0.

Type :b for backtrace, :c <option number> to proceed,  or :? for other 
options

CL-USER 2 : 1 >


I don't suppose that there is some switch in Lispworks to turn off the 
printing of error messages?

--dennis
From: Zehao Chen
Subject: Re: Newbie question: Bool Function returns neither True nor False?
Date: 
Message-ID: <b9hqos$1qqr$1@mail.cn99.com>
I am using LispWorks Personal Edition 4.2 for Linux.

I have tried the same command again and it displayed exactly what you 
had seen.

Funny. Things were different when I tried it yesterday.

Maybe
(proclaim '(optimize (safe 3))) takes effect?


Dennis Dunn wrote:
> Zehao Chen wrote:
> 
>> Thanks for all.
>>
> <snip>
> 
> FWIW, I'm using Lispworks Personal Edition 4.2 on WinXP and this is what 
> I get when I type that form in the listener --
> 
> CL-USER 1 > (evenp 'a)
> 
> Error: In EVENP of (A) arguments should be of type INTEGER.
>   1 (continue) Return a value to use.
>   2 Supply a new argument.
>   3 (abort) Return to level 0.
>   4 Return to top loop level 0.
> 
> Type :b for backtrace, :c <option number> to proceed,  or :? for other 
> options
> 
> CL-USER 2 : 1 >
> 
> 
> I don't suppose that there is some switch in Lispworks to turn off the 
> printing of error messages?
> 
> --dennis
>