bug-guile
[Top][All Lists]
Advanced

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

bug#48712: (is-a? #nil <list>) --> #f (oop goops)


From: Maxime Devos
Subject: bug#48712: (is-a? #nil <list>) --> #f (oop goops)
Date: Fri, 28 May 2021 10:59:05 +0200
User-agent: Evolution 3.34.2

I want to make sure some Scheme code using (oop goops) can be used
from elisp. The method I'm defining is something like this (overly
simplified):

;; TODO: Define a <mach-port> instead of working with raw integers?
(define-method (send-message! (msg <message-box>) (data <list>) (remote 
<mach-port>))
  [ write data to msg ]
  [ call mach_msg appropriately ])

I tested whether elisp's #nil is considered a <list>, apparently not:

(use-modules (oop goops))

(is-a? '() <list>) ;; #t
(is-a? '(a . ()) <list>) ;; #t
(is-a? #nil <list>) ;; #f, expected #t
(is-a? '(a . #nil) <list>) ;; #t

(class-of '()) ;; <null>
(class-of '(a . ())) ;; <pair>
(class-of #nil) ;; <boolean>, expected (a subclass of) <null>
(class-of '(a . #nil)) ;; <pair>

#nil is both a boolean, and an end-of-list object.
As such, it should be both <boolean> and <null> (and <list>).
But currently it is only <boolean>.

My untested suggestion:
Define a class <elisp-nil>, inheriting from <boolean> and <null>.
Define class_elisp_nil appropriately in libguile/goops.c and (oop goops).
In scm_class_of, adjust

    case scm_tc3_imm24:
      if (SCM_CHARP (x))
        return class_char;
      else if (scm_is_bool (x))
        return class_boolean;
      else if (scm_is_null (x))
        return class_null;
      else
        return class_unknown;

appropriately.

Greetings,
Maxime

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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