[Top][All Lists]

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

Re: A value for "nothing"

From: HiPhish
Subject: Re: A value for "nothing"
Date: Thu, 13 Sep 2018 23:49:10 +0200

After taking the advice from the mailing list users this is what I have come 
up with:

    (define-module (msgpack nil)
      #:use-module ((srfi srfi-9) #:select (define-record-type))
      #:export (nil? (get-nil . nil)))
    (define-record-type nil
      (make-nil)  ; The raw constructor will not get exported
    (define get-nil  ; This will be renamed on export
      (let ((the-nil (make-nil)))  ; Singleton instance
        (λ ()
          "- Scheme procedure: nil
      Return the unique object representing nothingness in MessagePack.
      All calls to this procedure return objects which are 'eq?' to each 

The procedure `get-nil` gets exported as `nil` and returns a singleton 
instance of my `nil` type. This way `(eq? (nil) (nil))` is always `#t`. The 
only issues is that the `nil?` predicate collides with Guile's own `nil?` 
predicate, so users will have to prefix or rename it when importing. I would 
prefer not to export these two procedures with prefixes like `msgpack-nil` out 
of the box, it's really ugly :/ What is the difference between `nil?` and 
`null?` anyway? The former is not listed in the procedure index of the Guile 

What do you think?

reply via email to

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