unofficial mirror of 
 help / color / mirror / Atom feed
* 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

;; 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;
        return class_unknown;



[-- 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

unofficial mirror of 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror guile-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-bugs guile-bugs/ \
	public-inbox-index guile-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:

AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git