[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
nil?)
(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
other."
the-nil)))
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
manual.
What do you think?
- Re: A value for "nothing",
HiPhish <=
- Message not available
- Re: A value for "nothing", HiPhish, 2018/09/14
- Re: A value for "nothing", John Cowan, 2018/09/14
- Re: A value for "nothing", HiPhish, 2018/09/15
- Re: A value for "nothing", Keith Wright, 2018/09/15
- Re: A value for "nothing", Edwin Watkeys, 2018/09/15
- Re: A value for "nothing", HiPhish, 2018/09/15
- Re: A value for "nothing", Edwin Watkeys, 2018/09/15
- Re: A value for "nothing", HiPhish, 2018/09/15
- Re: A value for "nothing", David Pirotte, 2018/09/15