guile-user
[Top][All Lists]
Advanced

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

Re: A value for "nothing"


From: Thomas Morley
Subject: Re: A value for "nothing"
Date: Sun, 26 Aug 2018 19:21:50 +0200

2018-08-26 12:13 GMT+02:00 HiPhish <address@hidden>:
> 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?

Well, actually that's how the value of *unspecified* is defined.

>From boot9.scm:

;;; {The Unspecified Value}
;;;
;;; Currently Guile represents unspecified values via one particular value,
;;; which may be obtained by evaluating (if #f #f). It would be nice in the
;;; future if we could replace this with a return of 0 values, though.
;;;

(define-syntax *unspecified*
  (identifier-syntax (if #f #f)))

(define (unspecified? v) (eq? v *unspecified*))



Cheers,
  Harm

>
> 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] https://msgpack.org/
> [2] http://docs.racket-lang.org/reference/void.html?q=void
> [3] https://gitlab.com/HiPhish/MsgPack.rkt/blob/master/msgpack/unpack.rkt#L47
> [4] https://gitlab.com/HiPhish/MsgPack.rkt/blob/master/msgpack/pack.rkt#L35
>
>
>



reply via email to

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