guile-user
[Top][All Lists]
Advanced

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

Re: A value for "nothing"


From: Mark H Weaver
Subject: Re: A value for "nothing"
Date: Tue, 28 Aug 2018 02:58:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Matt Wette <address@hidden> writes:

> Is it reasonable to expect that if a value can be assigned to a variable
> then a predicate exists to test for that value type?  So, if
>
>   (define a (if #f #f))
>
> does not signal an error then there should be a predicate to indicate the
> value associated with a is unspecified?
>
> If the define allowed in RnRS?  I don't believe there is a predicate to
> test for this. (I could be wrong.)

In RnRS, (define a (if #f #f)) is allowed and guaranteed to assign
*some* object to 'a' without signalling an error.  However, it's not
specified what object will be assigned.  It could be 2 or (foo bar) or
"the cow jumps over the moon".

So, in RnRS, there's no predicate that you could apply to 'a' and be
assured that the result will be #t on all conforming implementations.

Guile has always had a predicate 'unspecified?' since at least 1996, but
personally I would advise against relying on its continued existence in
the future.

Regarding your question whether it's reasonable to expect that every
object has an associated predicate to test for it, I don't know.  It's
an interesting question, but I wonder what would be the practical use of
such an expectation?

Given the fact that there are several mechanisms to add new types that
are distinct from all other types, and that we occasionally add new core
types to Guile that no previously extant predicate would answer #t for,
you certainly cannot rely on being able to write a 'cond' statement that
tests an arbitrary object using some set of predicates and be assured
that at least one of those predicates will answer #t.  You could write
such a 'cond' statement today with that property, but for a future
version of Guile you might find an object for which none of those
predicates returns #t.

     Regards,
       Mark



reply via email to

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