unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 48712@debbugs.gnu.org
Subject: bug#48712: (is-a? #nil <list>) --> #f (oop goops)
Date: Fri, 28 May 2021 10:59:05 +0200	[thread overview]
Message-ID: <624661bacce9263eac189a51b7d2774864f9c6b8.camel@telenet.be> (raw)

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

                 reply	other threads:[~2021-05-28  8:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=624661bacce9263eac189a51b7d2774864f9c6b8.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=48712@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).