Subject: [clisp-list] CLisp or Me, take three?

From: Douglas Philips <[email-masked]>
Date: Fri Aug 22 13:40:05 2003

% cat test3.lisp
(defclass t1 () ( (foo :accessor foo :initform :foo)))

(defun test-me ()
         (let ((a (make-instance 't1)))
                 (if (typep a 't1)
                         (format t "worked~%")
                         (format t "failed!~%"))))

(test-me)

% clisp test3
worked
% clisp -C test3
failed!

Man, I just hate chasing these kinds of bugs. No more -C for me for a 
while.

<D\'gou

---

From: Sam Steingold <[email-masked]>
Date: Fri Aug 22 13:43:00 2003

> * In message <[email-masked]>
> * On the subject of "CLisp or Me, take three?"
> * Sent on Fri, 22 Aug 2003 11:29:33 -0400
> * Honorable Douglas Philips <[email-masked]> writes:
>
> % cat test3.lisp

thank you very much for your rigorous testing and concise test cases.
please try the appended patch.

> Man, I just hate chasing these kinds of bugs. No more -C for me for a

this just means that the bugs will be discovered later (if ever) and
you will have to deal with them in a release.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Parachute for sale, used once, never opened, small stain.

Index: compiler.lisp
===================================================================
RCS file: /cvsroot/clisp/clisp/src/compiler.lisp,v
retrieving revision 1.133
diff -u -w -b -u -b -w -i -B -r1.133 compiler.lisp
--- compiler.lisp	20 Aug 2003 22:56:59 -0000	1.133
+++ compiler.lisp	22 Aug 2003 20:27:01 -0000
@@ -4250,7 +4250,7 @@
      :sub-anodes '()
      :seclass '(NIL . NIL)
      :code (if *for-value*
-               `((CONST ,(if *compiling-from-file*
+               `((CONST ,(if *fasoutput-stream*
                            (if (and (symbolp form) (c-constantp form))
                              (make-const :horizon ':all :form form
                                          :value (c-constant-value form))

---

From: Douglas Philips <[email-masked]>
Date: Sat Aug 23 14:49:03 2003

> please try the appended patch.

The cvs HEAD that I checked out this AM seems to have that patch!
It looks as if it solves test1, test2 and test3 issues.
Thanks for such fast turn around!

> you will have to deal with them in a release.

I really hope that the two branch source will make that a lot less 
painful if/when it happens.

Sorry for being so terse/harsh. So far the test cases have been 
somewhat easy to identify. I went looking at compiler.lisp and am 
puzzled by the dichotomy of tests, and when testing *fasoutput-stream* 
is done and when testing *compiling-from-file* (and what about plain 
ol' *compiling* ??)

I'll keep playing with -C, but only after I believe the code works 
interpreted and as compiled as a file. ;-)

<D\'gou

---

From: amit phalgune <[email-masked]>
Date: Sat Aug 23 14:54:10 2003

Hi ,
I am getting the following error .
Does anyone have an idea what this error is. and How I can solve it.

*** - DEFGENERIC DESTROY: The only valid method combination is STANDARD :
(:METHOD-COMBINATION PROGN)

Thanks
Amit

---

From: Sam Steingold <[email-masked]>
Date: Sat Aug 23 18:57:03 2003

> * In message <[email-masked]>
> * On the subject of "NewBie Problem"
> * Sent on Sat, 23 Aug 2003 14:53:33 -0700 (PDT)
> * Honorable amit phalgune <[email-masked]> writes:
>

<http://clisp.cons.org/impnotes.html#objects>:
"Only the STANDARD method combination is implemented."

patches are welcome

--
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Life is like a diaper -- short and loaded.

---

From: amit phalgune <[email-masked]>
Date: Wed Aug 27 12:27:41 2003

Hi,
Does anyone know how to get the current directory using clisp.

There is a current-directory function in Allegro CL. Does CLISP have a
similar function.

Amit

---

From: "John K. Hinsdale" <[email-masked]>
Date: Wed Aug 27 12:42:52 2003

> There is a current-directory function in Allegro CL. Does CLISP have a

Check the TOC of implementation notes at:

   http://clisp.sourceforge.net/impnotes/

There is a link from there to Chapter 20, "Files"

   http://clisp.sourceforge.net/impnotes/files.html

In section 20.1.1 "Function DIRECTORY" is described a function EXT:CD
which will return the current directory, or, with an argument will set
it.

Many, many other questions can be answered by scanning these
implementation notes.

---
John Hinsdale, Alma Mater Software, Inc., Tarrytown, NY 10591-3710 USA
[email-masked] | http://www.alma.com/staff/hin | +1 914 631 4690

---

From: amit phalgune <[email-masked]>
Date: Thu Aug 28 19:30:03 2003

Hi ,
 There is an error I am facing.  I
 have digged into the error and looks like CLISP does not support any
other
 method-combination other than STANDARD.

 Now our code  uses a defgeneric with the
method-combination as "progn".( which looks like a customized
 method-combination for defgeneric.

 (defgeneric destroy (a) (:method-combination progn))
I am new to LISP and so I am not sure what exactly is defgeneric used
for. Also CLISP supports only STANDARD method-combination. Is progn used
above a customized method combination. How can I get a work around so that
the above code works fine in CLISP.

 Thanks in advance,
 Amit

---

From: David Morse <[email-masked]>
Date: Thu Aug 28 19:58:02 2003

> the above code works fine in CLISP.

The easiest thing, since you probably have full sources, is to go
through all (defmethod destroy progn ((... calls, take out the word
"progn", then put a (call-next-method) at the beginning (or is it the
end?) of each defmethod body.

--David)))

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Thu Aug 28 20:24:14 2003

> end?) of each defmethod body.

Perhaps it  would be even easier,  since you have the  full sources of
clisp available, to implement the PROGN method-combination in clisp...
(and then contribute it to the maintainers of clisp ;-)

-- 
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
Do not adjust your mind, there is a fault in reality.

---

From: amit phalgune <[email-masked]>
Date: Fri Aug 29 09:20:03 2003

Hi,

 I replaced "progn" with (call-next-method)

(defgeneric destroy (a :method-combination (call-next-method)))

But I get the following error :

*** - DEFGENERIC DESTROY: variable name (CALL-NEXT-METHOD) should be a
symbol
1. Break [3]>

Please help !!
Amit

On Thu, 28 Aug 2003, David Morse wrote:

> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> clisp-list mailing list
> [email-masked]
> https://lists.sourceforge.net/lists/listinfo/clisp-list
>

---

From: amit phalgune <[email-masked]>
Date: Fri Aug 29 09:20:08 2003

Hi David,
Thanks for the reply. Do you mean that I change the progn to
call-next-method.
There is just one defmethod with progn in the source I have.
But I still have a doubt. I have basically not understood what the
defgeneric code is doing.
It all seems to be related to classes and instances and the methods
associated with it..
But I am extremely unclear and confused abt it. I tried to look on the net
for the related documents.. but since I am not aware of OO lisp, or for
that matter even normal LISP ( i have just begun coding in LISP).. I am
not able to understand what that code is supposed to do and why and what
happens if we replace progn with (call-next-method)

I will be extremely grateful if you can kindly explain it to me...

Thanking you,
Amit

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Fri Aug 29 15:25:07 2003

amit phalgune writes:
> that matter even normal LISP ( i have just begun coding in LISP).. 

One essential  resource for Common-Lisp programmers  is obviously: The
Common-Lisp HyerSpec at:

       http://www.lisp.org/
       http://www.lisp.org/HyperSpec/FrontMatter/Chapter-Index.html

There is a chapter on Objects:

       http://www.lisp.org/HyperSpec/Body/chap-7.html

See also:  http://www.cliki.org/  for links.

> I am not able to understand what that code is supposed to do and why
> and what happens if we replace progn with (call-next-method)
> 

defgeneric  just defines an  interface to  a generic  operation.  Once
defined,  the  system will  know  that  any  function call  with  this
function  name should  be  dispatched  depending on  the  type of  the
arguments, selecting a method.

Introduction to Generic Functions:
       http://www.lisp.org/HyperSpec/Body/sec_7-6-1.html

Since there may be multiple inheritance of objects, several method may
apply for on generic call. The  question is then in what order to call
the various methods.

In  other object oriented  languages, usually  only the  most specific
method is invoked (but with multiple inheritance, there may be no most
specific method).  So defgeneric allow  you to specify a default order
for the method invocation, and you can do it when defining each method
too.
      http://www.lisp.org/HyperSpec/Body/sec_7-6-6.html

> > >  (defgeneric destroy (a) (:method-combination progn))

Since   you're  implementation   does  not   know  the   progn  method
combination, you may choose  another order yourself. Check the various
destroy methods  you have  and determine in  which order they  must be
run.  If they have to be run  from the most specific first to the less
specific last, it's :before.  Otherwise, it's :after.  If the order is
more complicated  (unlikely since it  was specified progn),  you would
use :arround, and  in each method, you could specify  when to call the
less specific method with (call-next-method).

So, removing (:method-combination progn) from the defgeneric,
and adding :before to the defmethod destroy, 
could be the solution:

      (defgeneric destroy (a))
      (defmethod  destroy :before ((a class-1) #| ... |# )
      (defmethod  destroy :before ((a class-2) #| ... |# )

---

From: David Morse <[email-masked]>
Date: Fri Aug 29 16:32:05 2003

>      (defmethod  destroy :before ((a class-2) #| ... |# )

Hey, yah, using :before is better than my idea of embedding 
(call-next-method).  You have to ensure that there's at least one 
applicable main method though:

(defmethod destroy ((whatever t))
  ;; do nothing
  )

The downside of the :before approach is that it doesn't correctly 
simulate the return value, but given the name of the function is 
DESTROY, I doubt your callers care.

---

From: amit phalgune <[email-masked]>
Date: Fri Aug 29 22:12:04 2003

Does anyone know what causes this error. I have a defclass on RGNCRGNODE
(defclass RgnCRGNode (CRGNode Rect)())
now when I try to call a defmethod,
e.g :
(defmethod XYZ ((abc RgnCRGNode))
I get the following error..

*** - FIND-CLASS: RGNCRGNODE does not name a class

Can anyone guide me..
Amit

---

From: amit phalgune <[email-masked]>
Date: Fri Aug 29 22:14:03 2003

Hi guys,
Thanks a lot for the help and the detailed replies. I was finally able to
take care of the problem with you help.. Thanks for helping a newbie..

Really appreciate it ..
Let the help keep coming .
Amit

---

From: Pascal J.Bourguignon <[email-masked]>
Date: Fri Aug 29 22:26:02 2003

> *** - FIND-CLASS: RGNCRGNODE does not name a class

As you may have noticied, names following capitalizing conventions are
not well  fit to the  lisp way of  life.  You should rather  use names
such as: rgn-crg-node.

With (defmethod xyz  ((abc rgncrgnode)) ... ) you  are not calling the
method,  you are  defining  it.   Calling the  method  would be,  thru
sending a message: (xyz a-rgncrgnode-instance).

Otherwise,  you  gave  too   little  information  to  receive  helpful
feedback.

(defclass rect () ())
(defclass crg-node () ())
(defclass rgn-crg-node (crg-node rect) ())
(defmethod xyz((abc rgn-crg-node)))

works perfectly well:

[107]> (defclass rect () ())
(defclass rect () ())
#<STANDARD-CLASS RECT>
[108]> (defclass crg-node () ())
#<STANDARD-CLASS CRG-NODE>
[109]> (defclass rgn-crg-node (crg-node rect) ())
#<STANDARD-CLASS RGN-CRG-NODE>
[110]> (defmethod xyz((abc rgn-crg-node)))
#<STANDARD-METHOD (#<STANDARD-CLASS RGN-CRG-NODE>)>
[111]> (xyz (make-instance 'rgn-crg-node))
NIL
[112]>