|
Re: SV: strange macro "or" behavior in CormanLisp2.01: msg#00024lisp.corman
At 12:39 PM 3/5/03 +0100, Pavel Grozman wrote: >CormanLisp tries to evaluate constant subexpressions. >Without constants it works as it should: > >(setq x 0) >0 >(or 13 (/ 1 x)) >13 > More precisely, Corman is not doing evaluation. Corman always compiles everything, even things you type into it interactively. So the Corman compiler is walking over the form (/ 1 0), noticing that it is composed completely of constant forms, and trying to collapse the expression into a single value, much as it would collapse (+ 1 1) at compile time into '2'. But it doesn't currently test whether its attempt to collapse the expression succeeds or fails; if the expression it is collapsing causes an error, that error is allowed to be signalled at compile time. As Roger and I have discussed elsewhere, this is not correct ANSI Common Lisp semantics. The compiler should produce code which will cause the error condition to be raised when the function is run, and it should probably generate a warning about the offending expression. > > I've noticed the following when I was doing a excercise in > > Paul Graham's ANSI Common Lisp: > > > > [Corman Common Lisp 2.01] > > (or 13 (/ 1 0)) > > ;;; An error occurred in function /: > > ;;; Error: Divide by zero error: 1 / 0 > > ----snip---- > > > > [Allegro Common Lisp 6.2] > > CL-USER(1): (or 13 (/ 1 0)) > > 13 > > CL-USER(2): Note that the compiler is not currently collapsing expressions such as (or 13 (/ 1 0)) to '13' but it legitimately could, just as it could (but does not now) collapse something like (if t (foobar x) (foobaz x)) into a call to FOOBAR. (Allegro does collapse this expression, to the point of not even warning you that FOOBAZ is an undefined function, while warning you that FOOBAR is undefined!) ------------------------ Yahoo! Groups Sponsor ---------------------~--> Get 128 Bit SSL Encryption! http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/SyjtlB/TM ---------------------------------------------------------------------~-> To unsubscribe from this group, send an email to: cormanlisp-unsubscribe@xxxxxxxxxxxxxxx Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | SV: strange macro "or" behavior in CormanLisp2.01: 00024, Pavel Grozman |
|---|---|
| Next by Date: | Bug in SUBSEQ when accessing simple bit vectors: 00024, xenophonf |
| Previous by Thread: | SV: strange macro "or" behavior in CormanLisp2.01i: 00024, Pavel Grozman |
| Next by Thread: | Bug in SUBSEQ when accessing simple bit vectors: 00024, xenophonf |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |