[Top][All Lists]

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

Re: A value for "nothing"

From: Panicz Maciej Godek
Subject: Re: A value for "nothing"
Date: Mon, 27 Aug 2018 02:17:06 +0200

niedz., 26 sie 2018 o 16:09 HiPhish <address@hidden> napisał(a):

> 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 my experience, if #f doesn't make sense as a legal value, then using #f
is probably the idiomatic Scheme way to go.
It composes with SRFI-2's and-let* in a way similar to Haskell's Nothing
within the "do" notation.
I did find it useful when I was implementing a pattern matching facility,
where I could distinguish between an empty list of (successful) bindings
and a failed match.
But I think you would need to tell us more about the library: where do the
values come from and what do they represent. What would this "nil" data
type be supposed to stand for?

reply via email to

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