Subject: [clisp-list] error or warning during compilation, yet some function is generat ed

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Tue Apr 29 07:06:13 2003

Hi,

I wonder about the following behaviour

[21]> (lambda(s)(declare (compile))(ffi:with-foreign-string (f s :foo 1) (values f s)))
;NB: This form is erroneous.

ERROR in :LAMBDA-2 :
Constant :FOO cannot be bound.
WARNING in LAMBDA :
variable S is not used.
Misspelled or missing IGNORE declaration?
#<COMPILED-CLOSURE :LAMBDA>

; I.e. an error is reported, yet compilation continues, and returns a weird function object:

[22]> (funcall *)
NIL
[23]> (disassemble **)

Disassembly of function :LAMBDA
0 required arguments
0 optional arguments
No rest parameter
No keyword parameters
2 byte-code instructions:
0     (NIL)
1     (SKIP&RET 1)
#<COMPILED-CLOSURE :LAMBDA>
;I.e. a function which takes no arguments(! -- where did S go?) and returns NIL.

This behaviour is different from doing
[24]> (defun foo (s) (ffi:with-foreign-string (f s :foo 1) (values f s)))
FOO
[25]> (compile *)
ERROR in FOO-2 :
Constant :FOO cannot be bound.
WARNING in FOO :
variable S is not used.
Misspelled or missing IGNORE declaration?
NIL ;
2 ;
1
No function was produced in this case, which I feel fine.

Comments welcome,
	Jörg Höhle

---

From: Sam Steingold <[email-masked]>
Date: Wed Apr 30 07:13:02 2003

> * In message <[email-masked]>
> * On the subject of "[clisp-list] error or warning during compilation, yet some function is generat ed"
> * Sent on Tue, 29 Apr 2003 16:05:31 +0200
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>

this appears to be the intended behavior in COMPILE-LAMBDA
(compiler.lisp)
I can easily disable it, but I would love to hear why Bruno introduced it.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat9 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Sinners can repent, but stupid is forever.

---

From: Bruno Haible <[email-masked]>
Date: Wed Apr 30 09:58:13 2003

> I can easily disable it, but I would love to hear why Bruno introduced it.

I don't see a good reason anymore not to give an
    (sys::error-of-type 'sys::source-program-error ...)

Bruno

---

From: Sam Steingold <[email-masked]>
Date: Wed Apr 30 10:56:20 2003

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] error or warning during compilation, yet some function is generat ed"
> * Sent on Wed, 30 Apr 2003 18:55:43 +0200 (CEST)
> * Honorable Bruno Haible <[email-masked]> writes:
>
> Sam writes:
> 

either this or just return nil, like we do now in other cases:

[1]> (defun f () (let ((:f 0)) :f))
F
[2]> (compile 'f)

ERROR in F :
Constant :F cannot be bound.
NIL ;
1 ;
1
[3]> (setq f (lambda () (let ((:f 0)) :f)))
#<CLOSURE :LAMBDA NIL (LET ((:F 0)) :F)>
[6]> (compile nil f)

ERROR :
Constant :F cannot be bound.
NIL ;
1 ;
1

returning NIL would violate the rule that (lambda ...) returns a
function, so, I guess, an error is better.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat9 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
There is an exception to every rule, including this one.