* bug#48712: (is-a? #nil <list>) --> #f (oop goops)
@ 2021-05-28 8:59 Maxime Devos
0 siblings, 0 replies; only message in thread
From: Maxime Devos @ 2021-05-28 8:59 UTC (permalink / raw)
To: 48712
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-28 8:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28 8:59 bug#48712: (is-a? #nil <list>) --> #f (oop goops) Maxime Devos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).