emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opaque objects and Emacs documentation


From: Tomas Hlavaty
Subject: Re: Opaque objects and Emacs documentation
Date: Tue, 21 Jul 2020 23:06:05 +0200

On Tue 21 Jul 2020 at 22:36, Eli Zaretskii <eliz@gnu.org> wrote:
>> >    . a function to compare two objects of this type
>> 
>> As discussed, it's a little function called 'equal'.
>
> Again, I envisioned a cl-defgeneric here.  Using 'equal' only works
> for simple forms, but if we are willing to limit ourselves to such
> simple forms, why do we need generics at all?

equal seems to also work for classes in emacs lisp (are they simple
forms?), because they are implemented on top of structs which emacs lisp
equal understands.

this is different than in common lisp

in emacs lisp:

   (defclass foo () ((hi :initarg :hi)))
   (equal (make-instance 'foo :hi 42) (make-instance 'foo :hi 42))
   => t

in common lisp:

   CL-USER> (defclass foo () ((hi :initarg :hi)))
   #<STANDARD-CLASS COMMON-LISP-USER::FOO>
   CL-USER> (equal (make-instance 'foo :hi 42) (make-instance 'foo :hi 42))
   NIL

there don't seem to be opaque objects in emacs lisp

   ;; -*- lexical-binding: t -*-
   (defun make-counter (n) (lambda () (incf n)))
   (equal (make-counter 42) (make-counter 42))
   => t
   (equal (make-counter 42) (funcall (make-counter 42)))
   => nil

what are opaque objects in emacs lisp?

what are non-simple forms?

CLOS seems to be spreading in Emacs which is a shame because it is
better to avoid it when writing robust and lasting software.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]