From: ··········@bbs.ee.ncu.edu.tw
Subject: Do me another favor OnLisp , please !
Date: 
Message-ID: <1134114845.318816.250330@z14g2000cwz.googlegroups.com>
I read OnLisp and found some problems that I couldn't resolve . The
following codes
is for the book's source code package (also can be seen in Page 267)
-------------------------------------------------------------------------
(defmacro =defun (name parms &body body)
  (let ((f (intern (concatenate 'string
                                "=" (symbol-name name)))))
    `(progn
       (defmacro ,name ,parms
         `(,',f *cont* ,,@parms))
       (defun ,f (*cont* ,@parms) ,@body))))
-------------------------------------------------------------------------
the  follwoing is what happens while I try to run the codes in ARC
Xlisp-stat
>
(defmacro =defun (name parms &body body)
  (let ((f (intern (concatenate 'string
                                "=" (symbol-name name)))))
    `(progn
       (defmacro ,name ,parms
         `(,',f *cont* ,,@parms))
       (defun ,f (*cont* ,@parms) ,@body))))

=DEFUN
> (=defun a b (list c))
Error: The function COMMA-AT is not defined.
Happened in: #<FSubr-LET: #dd3398>
> (=defun a b )
Error: The function COMMA-AT is not defined.
Happened in: #<FSubr-LET: #dd3398>
> (=defun a  '(b c) )
Error: The function COMMA-AT is not defined.
Happened in: #<FSubr-LET: #dd3398>
>
------------------------------------------------------------------------

My questions  is :  Is there anything wrong in my testing codes ?

I test the codes with those in Page 268 as the followings
>
(=defun bar (x)
(=values (list 'a (add1 x))))
Error: The function COMMA-AT is not defined.
Happened in: #<FSubr-LET: #dd3398>
>

So the codes again fails even for the book's own codes.

Thus my second question is : What does the author really want and what
should his codes be ?

(ps . I don't think the errors have anything to do with the lisp
implement , because eoor happens again while I try in clisp-2.35 , as
the followings:
[1]> (defmacro =defun (name parms &body body)
  (let ((f (intern (concatenate 'string
                                "=" (symbol-name name)))))
    `(progn
       (defmacro ,name ,parms
         `(,',f *cont* ,,@parms))
       (defun ,f (*cont* ,@parms) ,@body))))
=DEFUN
[2]> (=defun bar (x)
(=values (list 'a (add1 x))))

*** - EVAL: variable L has no value
The following restarts are available:
USE-VALUE      :R1      You may input a value to be used instead of L.
STORE-VALUE    :R2      You may input a new value for L.
ABORT          :R3      ABORT
Break 1 [3]>
*** - READ from
       #<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM>
         #<IO TERMINAL-STREAM>>
      : an object cannot start with #\)
The following restarts are available:
ABORT          :R1      ABORT
ABORT          :R2      ABORT
Break 2 [4]>
)

From: Pascal Bourguignon
Subject: Re: Do me another favor OnLisp , please !
Date: 
Message-ID: <878xuu73nu.fsf@thalassa.informatimago.com>
···········@bbs.ee.ncu.edu.tw" <··········@bbs.ee.ncu.edu.tw> writes:

> I read OnLisp and found some problems that I couldn't resolve . The
> following codes
> is for the book's source code package (also can be seen in Page 267)
> -------------------------------------------------------------------------
> (defmacro =defun (name parms &body body)
>   (let ((f (intern (concatenate 'string
>                                 "=" (symbol-name name)))))
>     `(progn
>        (defmacro ,name ,parms
>          `(,',f *cont* ,,@parms))
>        (defun ,f (*cont* ,@parms) ,@body))))
> -------------------------------------------------------------------------
> the  follwoing is what happens while I try to run the codes in ARC
> Xlisp-stat
>>
> (defmacro =defun (name parms &body body)
>   (let ((f (intern (concatenate 'string
>                                 "=" (symbol-name name)))))
>     `(progn
>        (defmacro ,name ,parms
>          `(,',f *cont* ,,@parms))
>        (defun ,f (*cont* ,@parms) ,@body))))
>
> =DEFUN
>> (=defun a b (list c))
> Error: The function COMMA-AT is not defined.
> Happened in: #<FSubr-LET: #dd3398>
>> (=defun a b )
> Error: The function COMMA-AT is not defined.
> Happened in: #<FSubr-LET: #dd3398>
>> (=defun a  '(b c) )
> Error: The function COMMA-AT is not defined.
> Happened in: #<FSubr-LET: #dd3398>

Obviously, you are not using a Common Lisp implementation.  
The lisp you're using doesn't know  ,@ 


You MUST lean Common Lisp if you want to be able to port Common Lisp
program to your lisp!  Read:

   A quick guide to getting set up to learn Common Lisp, the #lisp way: 
   http://www.unmutual.info/startingwithcl.html


   "Practical Common Lisp", an introduction to
    Common Lisp by Peter Seibel, available at
   http://www.gigamonkeys.com/book/ 
   and in dead-tree form from Apress (as of 11 April 2005).


   http://www.lispworks.com/reference/HyperSpec/




You can rewrite the macro as:

[50]> (defmacro =defun (name parms &body body)
  (let ((f (intern (concatenate 'string
                                "=" (symbol-name name)))))
    (list 'progn
          (list 'defmacro name parms
                (list* 'list (list 'quote f)
                       ''*cont*
                       parms))
          (list* 'defun f (list* '*cont* parms) body))))
=DEFUN
[51]> (macroexpand-1 '(=defun test (x y) (+ x y)))
(PROGN (DEFMACRO TEST (X Y) (LIST '=TEST '*CONT* X Y))
 (DEFUN =TEST (*CONT* X Y) (+ X Y))) ;
T
[52]> (=defun test (x y) (+ x y))
=TEST
[53]> (=test 'cont 1 2)
3
[54]> 


> ------------------------------------------------------------------------
>
> My questions  is :  Is there anything wrong in my testing codes ?
>
> I test the codes with those in Page 268 as the followings
>>
> (=defun bar (x)
> (=values (list 'a (add1 x))))
> Error: The function COMMA-AT is not defined.
> Happened in: #<FSubr-LET: #dd3398>
>>
>
> So the codes again fails even for the book's own codes.
>
> Thus my second question is : What does the author really want and what
> should his codes be ?
>
> (ps . I don't think the errors have anything to do with the lisp
> implement , because eoor happens again while I try in clisp-2.35 , as
> the followings:
> [1]> (defmacro =defun (name parms &body body)
>   (let ((f (intern (concatenate 'string
>                                 "=" (symbol-name name)))))
>     `(progn
>        (defmacro ,name ,parms
>          `(,',f *cont* ,,@parms))
>        (defun ,f (*cont* ,@parms) ,@body))))
> =DEFUN
> [2]> (=defun bar (x)
> (=values (list 'a (add1 x))))
>
> *** - EVAL: variable L has no value
> The following restarts are available:
> USE-VALUE      :R1      You may input a value to be used instead of L.
> STORE-VALUE    :R2      You may input a new value for L.
> ABORT          :R3      ABORT
> Break 1 [3]>
> *** - READ from
>        #<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM>
>          #<IO TERMINAL-STREAM>>
>       : an object cannot start with #\)
> The following restarts are available:
> ABORT          :R1      ABORT
> ABORT          :R2      ABORT
> Break 2 [4]>
> )

You didn't give =value.  =defun works perfectly well:


[39]> (defmacro =defun (name parms &body body)
  (let ((f (intern (concatenate 'string
                                "=" (symbol-name name)))))
    `(progn
       (defmacro ,name ,parms
         `(,',f *cont* ,,@parms))
       (defun ,f (*cont* ,@parms) ,@body))))
=DEFUN
[40]> (macroexpand-1 '(=defun test (x y) (+ x y)))
(PROGN (DEFMACRO TEST (X Y) (LIST '=TEST '*CONT* X Y))
 (DEFUN =TEST (*CONT* X Y) (+ X Y))) ;
T
[41]> (=defun test (x y) (+ x y))
=TEST
[42]> (=test 'cont 1 2)
3
[43]> 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
From: ··········@bbs.ee.ncu.edu.tw
Subject: Re: Do me another favor OnLisp , please !
Date: 
Message-ID: <1134142134.903988.86990@g49g2000cwa.googlegroups.com>
Pascal , I think you are right .
I tried in GNU common lisp and the codes compile well , thus I think
the problem is the compiler  use , not th codes from the book.

By the way, X-lisp stat knows the function of ,@ , as shown the
following test  :

> `(,@(list 1 2))
(1 2)
>

and CLISP is an ANSI Common Lisp Implementation , thus I think the
problems I encountered reveal the bugs in these 2 implementation .

Thanks !
From: Pascal Bourguignon
Subject: Re: Do me another favor OnLisp , please !
Date: 
Message-ID: <87r78m5lc3.fsf@thalassa.informatimago.com>
···········@bbs.ee.ncu.edu.tw" <··········@bbs.ee.ncu.edu.tw> writes:

> Pascal , I think you are right .
> I tried in GNU common lisp and the codes compile well , thus I think
> the problem is the compiler  use , not th codes from the book.
>
> By the way, X-lisp stat knows the function of ,@ , as shown the
> following test  :
>
>> `(,@(list 1 2))
> (1 2)
>
> and CLISP is an ANSI Common Lisp Implementation , thus I think the
> problems I encountered reveal the bugs in these 2 implementation .

CLISP has no problem:


[63]> (defpackage :olu (:use :cl))
#<PACKAGE OLU>
[64]> (in-package :olu)
#<PACKAGE OLU>
OLU[65]> (load"/home/pjb/src/lisp/doc/onlisp.lisp")
;; Loading file /home/pjb/src/lisp/doc/onlisp.lisp ...
;; Loaded file /home/pjb/src/lisp/doc/onlisp.lisp
T
OLU[66]> (defun add1 (x) (1+ x))
ADD1
OLU[67]> (=defun bar (x) (=values (list 'a (add1 x))))
=BAR
OLU[68]> (bar 2)
(A 3)
OLU[69]> 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"I have challenged the entire quality assurance team to a Bat-Leth
contest.  They will not concern us again."
From: Barry Margolin
Subject: Re: Do me another favor OnLisp , please !
Date: 
Message-ID: <barmar-160227.21135809122005@comcast.dca.giganews.com>
In article <·······················@g49g2000cwa.googlegroups.com>,
 ···········@bbs.ee.ncu.edu.tw" <··········@bbs.ee.ncu.edu.tw> wrote:

> Pascal , I think you are right .
> I tried in GNU common lisp and the codes compile well , thus I think
> the problem is the compiler  use , not th codes from the book.
> 
> By the way, X-lisp stat knows the function of ,@ , as shown the
> following test  :
> 
> > `(,@(list 1 2))
> (1 2)
> >
> 
> and CLISP is an ANSI Common Lisp Implementation , thus I think the
> problems I encountered reveal the bugs in these 2 implementation .
> 
> Thanks !

I suspect X-lisp stat has a problem with nested backquotes.

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***