Re: Strange error in CLISP



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
.



Relevant Pages

  • Re: vm02 update
    ... Instant Pascal was a misguided attempt at creating an IDE with automatic formatting and almost instant feedback. ... Editing the source in a tokenized format would keep the memory constraints lower and ease the first pass of the compiler. ... compiled to machine code at all. ...
    (comp.sys.apple2.programmer)
  • Re: OT: ASCII files and Intel P4 MMX instructions
    ... ASCII ... The file format is clean, one number per line, no fuzz. ... While I have played a bit with the settings in the compiler, ... are often dominated by the conversion from and to the external character ...
    (comp.dsp)
  • Re: replace statement and free format
    ... doesn't) that a vendor PRODUCE a compile-time listing of the source code. ... Free form reference format allows for each source line to have 255 characters ... - Depending on how many "passes" your compiler does of source code, ...
    (comp.lang.cobol)
  • Re: Deleting un(?)reachable code
    ... CDR form. ... Usually when I get these "deleting unreachable code" errors its because I did something stupid, generally rather far from the code which is flagged. ... Why does the compiler single out the format strings as ...
    (comp.lang.lisp)
  • Re: How does #last do it?!?!
    ... with optimizing compiler -- compiler can detect you're doing nothing ... (defun test (list) ... seconds of real time ...
    (comp.lang.lisp)

Loading