From: Miguel Arroz
Subject: How to make a CLOS method using lambda?
Date: 
Message-ID: <1090922737.841224@iceman.esoterica.pt>
Hi!

  I need to define a method using the lambda keyword. The problem is that 
the compiler is waiting for a function, not a method, so I get an error 
because the arguments are not in the expected form (some of them are 
objects). Is there a way to define a method using lambda?

  Yours

Miguel Arroz

From: Thomas A. Russ
Subject: Re: How to make a CLOS method using lambda?
Date: 
Message-ID: <ymi3c3de5lq.fsf@sevak.isi.edu>
Miguel Arroz <·····@guiamac.com> writes:
> 
>   I need to define a method using the lambda keyword. 

Why?  Tell us more about the real problem you are trying to solve.

> The problem is that 
> the compiler is waiting for a function, not a method, so I get an error 
> because the arguments are not in the expected form (some of them are 
> objects). Is there a way to define a method using lambda?

Have you looked at ADD-METHOD?

What have you tried that is giving you the error?

In any case, if you want to add a method, you need to first create an
object of type METHOD (STANDARD-METHOD?) to use with ADD-METHOD.
Unfortunately, exactly how to do that has not been officially
standardized, but Lisps that follow the MOP (MetaObject Protocol)
should support something like this:

  (make-instance 'STANDARD-METHOD
                 :lambda-list ...
                 :specializers ...
                 :function ...)


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Pascal Costanza
Subject: Re: How to make a CLOS method using lambda?
Date: 
Message-ID: <ce5fca$r0k$1@f1node01.rhrz.uni-bonn.de>
Miguel Arroz wrote:

>   I need to define a method using the lambda keyword. The problem is that 
> the compiler is waiting for a function, not a method, so I get an error 
> because the arguments are not in the expected form (some of them are 
> objects). Is there a way to define a method using lambda?

Could you post a code snippet that illustrates what you have already tried?


Pascal

-- 
Pascal Costanza               University of Bonn
···············@web.de        Institute of Computer Science III
http://www.pascalcostanza.de  R�merstr. 164, D-53117 Bonn (Germany)
From: Pascal Bourguignon
Subject: Re: How to make a CLOS method using lambda?
Date: 
Message-ID: <87k6wpbqfs.fsf@thalassa.informatimago.com>
Miguel Arroz <·····@guiamac.com> writes:

> Hi!
> 
>   I need to define a method using the lambda keyword. The problem is that 
> the compiler is waiting for a function, not a method, so I get an error 
> because the arguments are not in the expected form (some of them are 
> objects). Is there a way to define a method using lambda?

What do you mean? I can use the lambda macro inside a defmethod with
no problem:

(defmethod absolute ((n integer))  (sqrt ((lambda (x) (* x x)) n)))


I can even use the lambda symbol inside a defmethod with absolutely no
problem:

(defmethod consonants ((self greek-alphabet))
   '(beta gamma delta zeta theta kappa lambda 
     mu nu xi pi rho sigma tau phi chi psi))


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

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
From: Kaz Kylheku
Subject: Re: How to make a CLOS method using lambda?
Date: 
Message-ID: <cf333042.0407271624.43099282@posting.google.com>
Miguel Arroz <·····@guiamac.com> wrote in message news:<·················@iceman.esoterica.pt>...
> Hi!
> 
>   I need to define a method using the lambda keyword.

That would be a problem, because methods are defined using the
DEFMETHOD keyword.

Or do you mean you are trying to create a generic function called
LAMBDA?

The result of doing that is not well-defined by ANSI Common Lisp. Lisp
does not support transparent redefinition of standard functions,
macros or operators. (Transparent meaning that any existing
dependencies on the old definition are unaffected). This holds true
even if you restrict your redefinition to a lexical scope. Suppose you
redefine the APPEND function, and then in the same scope, you write a
backquote expression. The implementation is allowed to generate code
that uses APPEND, so the backquote-generated code may end up calling
your version of APPEND, which could break its correctness.

The way, in Common Lisp, to have completely unrestricted use of a
symbol that has a particular name, is to create your own package, and
create a symbol of that name in that package, setting it up as a
shadowing symbol (meaning that if another symbol by the same name is
made visible in your package, your symbol will implicitly win the
conflict).

;; Define a package through which the CL package is visible, but 
;; which has its own symbol called "LAMBDA":

(defpackage :my-package
  (:use :cl)
  (:shadow :lambda))

;; Now MY-PACKAGE::LAMBDA is a symbol

(in-package :my-package)

;; And now we are in that package, and we can refer to
;; my-package::lambda simply as lambda

(defgeneric lambda (x y))

;; If you want to use the standard Lambda here, you have to qualify
;; the symbol name:

(defmethod lambda (x y)
  (cl::lambda () (+ x y))
From: Rahul Jain
Subject: Re: How to make a CLOS method using lambda?
Date: 
Message-ID: <87llgvpyqy.fsf@nyct.net>
Miguel Arroz <·····@guiamac.com> writes:

>   I need to define a method using the lambda keyword. The problem is that 
> the compiler is waiting for a function, not a method, so I get an error 
> because the arguments are not in the expected form (some of them are 
> objects). Is there a way to define a method using lambda?

A method is a part of a generic-function. It is an implementation of
some functionality for a specific set of parameter types. A method is
not a function because there's no simple way to understand how to use it
as one. What is the term you really mean instead of method?

-- 
Rahul Jain
·····@nyct.net
Professional Software Developer, Amateur Quantum Mechanicist