Re: Strange error in CLISP
- From: tar@xxxxxxxxxxxxx (Thomas A. Russ)
- Date: 23 Jan 2009 15:29:56 -0800
blandest <Valentin.Baciu@xxxxxxxxx> writes:
....On 2009-01-23, blandest <Valentin.Ba...@xxxxxxxxx> wrote:
I'm running the following code in CLISP:
(defun test ()
Ž Ž (format t "~A"))
(compile 'test) ;; this is required to reproduce the error
(test)
Thanks, you and Pascal are right. I usually don't compile functions in
CLISP, but this time the source file was loaded into a lisp image
using mudballs. I removed the last parameter to #'format by mistake,
so the compiled function was wrong. Didn't expect the compiler to be
so permissive.
Well, I suppose part of it could be an issue of being permissive. But
perhaps more of it involves issues of how far a compiler is willing to
go in interpreting and checking format strings for correctness. Given
the very flexible nature of format string directives, especially
conditional and forward and backward skipping directives, it could be
rather tough in the general case.
So an implementation that didn't even bother to check at all doesn't
seem all that unreasonable.
As a simple example, is this code that should be flagged?
(defun test (flag)
(format t "~:[Works for nil! ~;~A~]" flag))
As long as you call TEST with NIL as an argument, it will work fine. So
it isn't necessarily broken, as long as it gets reasonable input.
Now, IMO this code is broken, or at least not very robust, since it will
fail with bad and unchecked inputs, but one could imagine more
complicated forms where it might be hard to see that there is a
problem. And perhaps there are some checks external to the format
statement to make sure that the bad input never gets there. A general
soluton would be just too hard for a compiler.
--
Thomas A. Russ, USC/Information Sciences Institute
.
- References:
- Strange error in CLISP
- From: blandest
- Re: Strange error in CLISP
- From: Kaz Kylheku
- Re: Strange error in CLISP
- From: blandest
- Strange error in CLISP
- Prev by Date: Re: Stupid? format question
- Next by Date: Re: Fexprs more flexible, powerful, easier to learn? (Newlisp vs CL)
- Previous by thread: Re: Strange error in CLISP
- Next by thread: Portable cross-module tail calling.
- Index(es):
Relevant Pages
|
Loading