Subject: [clisp-list] funcallable instance?

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Thu Mar 11 09:26:05 2004

Hi,

I was wondering whether it would be a valuable enhancement request to beg for funcall'able instances.

Pascal Costanza recently wrote in comp.lang.lisp:
>The following is in LispWorks 4.3 for Mac OS X.
(defclass changeable-function ()
   ((clambda :accessor clambda :initarg :clambda))
   (:metaclass funcallable-standard-class))

Remember's me of Python's __call__ method, which can be added to any instance, resulting in a callable object.

So is there a way to have a user-defined instance (e.g. it has slots I can define) that's a user-definable function at the same time, in CLISP?

I had thought about uses of such things, when the primary use of a "thing" was as a closure (I mean I'm working functionaly most of the time), but also some separate call could alter the closure's state (breaking the functional paradigm from times to times).

Calling another closure which shares bindigs can achieve this effect, but I'd be more satisfied with  maintaining a single object instead of two.

As a low-level hack, one could maybe define a setf method on some closure's environment vector, but uh...

Regards,
	Jörg Höhle

---

From: Sam Steingold <[email-masked]>
Date: Thu Mar 11 09:39:01 2004

> * Hoehle, Joerg-Cyril <[email-masked]> [2004-03-11 18:07:04 +0100]:
>

I think it would be a great idea to add FUNCALLABLE-STANDARD-CLASS,
as specified in MOP, see
<http://www.lisp.org/mop/concepts.html#funcallable-instances>

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>
Bill Gates is great, as long as `bill' is a verb.

---

From: Bruno Haible <[email-masked]>
Date: Thu Mar 11 10:37:33 2004

> <http://www.lisp.org/mop/concepts.html#funcallable-instances>

I think FUNCALLABLE-STANDARD-CLASS is a hack that some CLOS implementations
use to implement their generic-functions. It was rightfully not kept in CLOS
when ANSI CL was made, because
  1. normal function objects, slots and generic functions present enough ways
     to make intelligent, customizable, context-dependent functions,
  2. The problem with funcallable instances is that it doesn't scale:
     There is only one way to define a funcall of it. As soon as you wish
     to use the same mechanism for two different behaviours, you fail, Then
     you realize that you had better used a generic function.

Bruno