[Top][All Lists]

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

Re: A value for "nothing"

From: John Cowan
Subject: Re: A value for "nothing"
Date: Sun, 26 Aug 2018 13:49:29 -0400

Well, you could use #nil, a Guile-specific unique object that is both falsy
(like #f) and answers #t to the null? predicate.  It is used to emulate
Common Lisp's and Elisp's nil.  But a more portable approach would be to
define a record type with no slots and make just one instance of it.

On Sun, Aug 26, 2018 at 10:09 AM HiPhish <address@hidden> wrote:

> Hello Schemers,
> I am writing an implementation of MessagePack [1] for Guile and a part of
> the
> spec is the presence of a "nil" data type. What would be a good value to
> express "nothing" in Guile? I cannot use '() because that would be
> indistinguishable from the empty list, so I thought that the return value
> of a
> function that returns nothing would be a good fit. The function `display`
> for
> example returns an `#<unspecified>` value, but the only way of producing
> it
> without side effects so for is the value of `(if #f #f)`. Is there a
> better
> way?
> In Racket there is the `(void)` [2] procedure which returns a `#<void>`
> object, so that's what I am using there [3][4]. Any suggestions for Guile?
> [1]
> [2]
> [3]
> [4]

reply via email to

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