Hi all,
I appear to have uncovered a showstopper trying to port and compile
<http://homepage1.nifty.com/bmonkey/lisp/sacla/lisp/loop.lisp>.
I've distilled the issue down to this useless code fragment:
(defvar *environment*)
(defmacro env (tokens &body body &environment env)
`(let ((*environment* ,env))
,@body))
(let ((x 1))
(env '(+ 1 2) (print 123)))
The environment object needs to be externalizable for any extended-loop
macro to compile. Does anyone see how this can be avoided in the context
of Sacla loop?
Regards,
Adam
PS: The error messages had me puzzled for a while. SBCL says "There is no
MAKE-LOAD-FORM function for bootstrap type SB-KERNEL:LEXENV. CLISP is more
cryptic, e.g. the error message when compiling the above code is:
*** - COMMON-LISP::PRINT: Despite COMMON-LISP::*PRINT-READABLY*,
#1=#<SYSTEM::VAR COMMON-LISP-USER::X COMMON-LISP::NIL COMMON-LISP::T
#<SYSTEM::CONST 1. COMMON-LISP::NIL :VALUE> COMMON-LISP::NIL
COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL
COMMON-LISP::NIL COMMON-LISP::NIL
(0. 0. 0. 1. .
#2=#<SYSTEM::FNODE #3=#:|(LET (#) (ENV '# #))-3|
#Y(#3#
#21Y(00 00 00 00 00 00 00 00 00 01 C5 10 01 DC 38 01 31 82 11 19
01)
(COMMON-LISP::T COMMON-LISP::T COMMON-LISP::T)
#4=#(#(COMMON-LISP-USER::X #1# COMMON-LISP::NIL)
COMMON-LISP::NIL)
COMMON-LISP-USER::*ENVIRONMENT* 123.)
COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL 0.
COMMON-LISP::NIL 0. COMMON-LISP::NIL COMMON-LISP::NIL 0. 0. 0.
COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL
0. (#4# COMMON-LISP-USER::*ENVIRONMENT* 123.)
(COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL)
COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL COMMON-LISP::NIL
COMMON-LISP::NIL>)
(COMMON-LISP::NIL COMMON-LISP::NIL #2#) #2#> cannot be printed readably.
On Thu, 14 Apr 2005 00:58:22 +1200, Adam Warner wrote:
> The environment object needs to be externalizable for any extended-loop
> macro to compile. Does anyone see how this can be avoided in the context
> of Sacla loop?
Never mind. I've fortunately located the Symbolics update of the MIT LOOP
macro for ANSI Common Lisp. It includes a test suite and it's extensible:
<http://www-2.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/lang/lisp/code/iter/loop/symbolix/0.html>
It appears to have been last updated 4 December 1991, which means I may
have to make a few changes to bring it up to full conformance:
<http://www.lisp.org/HyperSpec/Issues/iss223-writeup.html>
Regards,
Adam
Hi, I'm the author of sacla loop. Thank you for the bug report.
I confirmed that sacla loop doesn't compile with clisp (at least) and
I think I've fixed the bug.
I just updated the file on the net.
http://homepage1.nifty.com/bmonkey/lisp/sacla/lisp/loop.lisp
http://homepage1.nifty.com/bmonkey/lisp/sacla/sacla.tar.gz
Thanks.
On Fri, 15 Apr 2005 00:36:29 -0700, Yuji Minejima wrote:
> Hi, I'm the author of sacla loop. Thank you for the bug report.
> I confirmed that sacla loop doesn't compile with clisp (at least) and
> I think I've fixed the bug.
>
> I just updated the file on the net.
> http://homepage1.nifty.com/bmonkey/lisp/sacla/lisp/loop.lisp
> http://homepage1.nifty.com/bmonkey/lisp/sacla/sacla.tar.gz
Thanks. Note that v 1.37 does not appear to compile with CLISP (nor SBCL).
GNU CLISP 2.33.2 (2004-06-02) (built 3318058917)
$ clisp -norc -ansi
WARNING: *FOREIGN-ENCODING*: reset to ASCII
[1]> (compile-file "loop.lisp")
Compiling file /home/adam/t/t65/loop.lisp ...
ERROR in CLAUSE* in lines 192..196 :
RETURN-FROM block NIL is impossible from here.
ERROR in MULTIPLE-VALUE-LIST-FORM-P in lines 374..380 :
RETURN-FROM block NIL is impossible from here.
ERROR in MULTIPLE-VALUE-LIST-FORM-P in lines 374..380 :
RETURN-FROM block NIL is impossible from here.
ERROR in MULTIPLE-VALUE-LIST-ARGUMENT-FORM in lines 382..391 :
RETURN-FROM block NIL is impossible from here.
ERROR in WITH-CLAUSE in lines 425..441 :
RETURN-FROM block NIL is impossible from here.
ERROR in FOR-AS-CLAUSE in lines 482..500 :
RETURN-FROM block NIL is impossible from here.
ERROR in FOR-AS-ARITHMETIC-SUBCLAUSE in lines 610..637 :
RETURN-FROM block NIL is impossible from here.
ERROR in FOR-AS-ARITHMETIC-SUBCLAUSE in lines 610..637 :
RETURN-FROM block NIL is impossible from here.
ERROR in CONDITIONAL-CLAUSE in lines 919..941 :
RETURN-FROM block NIL is impossible from here.
ERROR in CONDITIONAL-CLAUSE in lines 919..941 :
RETURN-FROM block NIL is impossible from here.
ERROR in VARIABLE-CLAUSE* in lines 961..963 :
RETURN-FROM block NIL is impossible from here.
ERROR in MAIN-CLAUSE* in lines 965..973 :
RETURN-FROM block NIL is impossible from here.
ERROR in REDUCE-REDUNDANT-CODE in lines 1078..1090 :
RETURN-FROM block NIL is impossible from here.
Deleted file /home/adam/t/t65/loop.fas
There were errors in the following functions:
SACLA-LOOP::CLAUSE* SACLA-LOOP::MULTIPLE-VALUE-LIST-FORM-P
SACLA-LOOP::MULTIPLE-VALUE-LIST-ARGUMENT-FORM SACLA-LOOP::WITH-CLAUSE
SACLA-LOOP::FOR-AS-CLAUSE SACLA-LOOP::FOR-AS-ARITHMETIC-SUBCLAUSE
SACLA-LOOP::CONDITIONAL-CLAUSE SACLA-LOOP::VARIABLE-CLAUSE*
SACLA-LOOP::MAIN-CLAUSE* SACLA-LOOP::REDUCE-REDUNDANT-CODE
The following functions were used but not defined:
SACLA-LOOP:LOOP
13 errors, 0 warnings
NIL ;
13 ;
13
Here's an addition to globally-special-p:
#+abcl (values (EXT:SPECIAL-VARIABLE-P symbol t))
Here's a small improvement to the loop macro:
(defmacro loop (&rest forms)
(if (symbolp (car forms))
`(extended-loop ,@forms)
`(simple-loop ,@forms)))
An infinite (loop) has a (car forms) of nil. nil is a symbol as well as
an empty list. I believe the final loop macro should ideally be:
(defmacro loop (&rest forms)
(if (or (null forms) (consp (car forms)))
`(simple-loop ,@forms)
`(extended-loop ,@forms)))
Regards,
Adam
Adam Warner suggested to replace
> (defmacro loop (&rest forms)
> (if (symbolp (car forms))
> `(extended-loop ,@forms)
> `(simple-loop ,@forms)))
with
> (defmacro loop (&rest forms)
> (if (or (null forms) (consp (car forms)))
> `(simple-loop ,@forms)
> `(extended-loop ,@forms)))
This still doesn't match the specification in ANSI CL 6.1.1.1.
The real fix is
(defmacro loop (&rest forms)
(if (every #'consp forms)
`(simple-loop ,@forms)
`(extended-loop ,@forms)))
Here I assume you haven't implemented EVERY using LOOP; otherwise you
have a bootstrapping problem :-)
Bruno
Hi, Bruno san.
Thanks for the hint. I took your advice and changed the code.
P.S. I'm currently designing a virtual machine for Sacla which will be
simple, portable and versatile while awfully slow.
Regards,
Yuji
Adam Warner <······@consulting.net.nz> wrote in message news:<······························@consulting.net.nz>...
> Thanks. Note that v 1.37 does not appear to compile with CLISP (nor SBCL).
You are right. It seems that it needs to be loaded before getting
compiled. The following scheme seems to work.
CL-USER> (lisp-implementation-type)
"CLISP"
CL-USER> (lisp-implementation-version)
"2.33.2 (2004-06-02) (built 3318073317) (memory 3322541745)"
CL-USER> (cd "lisp")
#P"/usr/local/src/lisp/sacla/lisp/"
CL-USER> (load "share.lisp")
;; Loading file share.lisp ...
;; Loaded file share.lisp
T
CL-USER> (load "loop.lisp")
;; Loading file loop.lisp ...
;; Loaded file loop.lisp
T
CL-USER> (compile-file "loop.lisp")
Compiling file /usr/local/src/lisp/sacla/lisp/loop.lisp ...
Wrote file /usr/local/src/lisp/sacla/lisp/loop.fas
0 errors, 0 warnings
#P"/usr/local/src/lisp/sacla/lisp/loop.fas"
NIL
NIL
CL-USER> (load "loop")
;; Loading file /usr/local/src/lisp/sacla/lisp/loop.fas ...
;; Loaded file /usr/local/src/lisp/sacla/lisp/loop.fas
T
I must confess I haven't payed much attention to compiling and
building process and I'm sorry to waste your time.
> Here's an addition to globally-special-p:
>
> #+abcl (values (EXT:SPECIAL-VARIABLE-P symbol t))
>
Thanks. I added the code.
loop.lisp version 1.38 is available here.
http://homepage1.nifty.com/bmonkey/lisp/sacla/lisp/loop.lisp
http://homepage1.nifty.com/bmonkey/lisp/sacla/sacla.tar.gz
Regards,
Yuji