[PATCH] doc: Document undefined?.

  • Done
  • quality assurance status badge
Details
2 participants
  • Arun Isaac
  • Mark H Weaver
Owner
unassigned
Submitted by
Arun Isaac
Severity
normal
A
A
Arun Isaac wrote on 17 Jan 2018 18:52
(address . bug-guile@gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20180117175204.1381-1-arunisaac@systemreboot.net
* doc/ref/data-rep.texi: Document undefined?.
---
doc/ref/data-rep.texi | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (16 lines)
diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi
index bb7f74afe..ed3a5a522 100644
--- a/doc/ref/data-rep.texi
+++ b/doc/ref/data-rep.texi
@@ -470,6 +470,9 @@ check to see if @var{x} is @code{SCM_UNBOUND}. History will not be kind
to us.
@end deftypefn
+@deffn {Scheme Procedure} undefined? x
+Return @code{#t} if @var{x} is undefined, else @code{#f}.
+@end deffn
@node Non-immediate objects
@subsubsection Non-immediate objects
--
2.15.1
A
A
Arun Isaac wrote on 18 Jan 2018 07:16
Re: bug#30145: Acknowledgement ([PATCH] doc: Document undefined?.)
(address . 30145@debbugs.gnu.org)
cu71sinu1xn.fsf@systemreboot.net
I intended to document unspecified?. I have somehow gotten confused and
ended up specifying it as undefined?. Disregard this patch. I will send
a new one.
A
A
Arun Isaac wrote on 18 Jan 2018 07:20
[PATCH] doc: Document unspecified?.
(address . 30145@debbugs.gnu.org)(name . Arun Isaac)(address . arunisaac@systemreboot.net)
20180118062029.5655-1-arunisaac@systemreboot.net
* doc/ref/data-rep.texi: Document unspecified?.
---
doc/ref/data-rep.texi | 3 +++
1 file changed, 3 insertions(+)

Toggle diff (16 lines)
diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi
index bb7f74afe..f179a3560 100644
--- a/doc/ref/data-rep.texi
+++ b/doc/ref/data-rep.texi
@@ -470,6 +470,9 @@ check to see if @var{x} is @code{SCM_UNBOUND}. History will not be kind
to us.
@end deftypefn
+@deffn {Scheme Procedure} unspecified? x
+Return @code{#t} if @var{x} is unspecified, else @code{#f}.
+@end deffn
@node Non-immediate objects
@subsubsection Non-immediate objects
--
2.15.1
M
M
Mark H Weaver wrote on 21 Jan 2018 15:33
Re: bug#30145: [PATCH] doc: Document undefined?.
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 30145@debbugs.gnu.org)
871sijnuwr.fsf@netris.org
Arun Isaac <arunisaac@systemreboot.net> writes:
Toggle quote (2 lines)
> * doc/ref/data-rep.texi: Document undefined?.

Is 'undefined?' a procedure in your Guile? It's not available at my
Guile REPL,and I can't find a single occurrence of 'undefined?' in my
guile stable-2.2 git checkout.

There is a special SCM_UNDEFINED value at the C level, but it's only
used for a couple of internal purposes and not usable from Scheme at
all.

FYI, the two internal purposes are these: (1) if SCM_UNDEFINED is passed
as an optional argument to a Scheme procedure implemented in C, this
indicates that the optional argument was not actually present. (2) if
SCM_UNDEFINED is stored in a top-level variable object, that indicates
that the variable is no longer bound, i.e. it was actually removed.

Mark
M
M
Mark H Weaver wrote on 21 Jan 2018 15:48
Re: bug#30145: [PATCH] doc: Document unspecified?.
(name . Arun Isaac)(address . arunisaac@systemreboot.net)(address . 30145@debbugs.gnu.org)
87wp0bmfmx.fsf@netris.org
Hi Arun,

Arun Isaac <arunisaac@systemreboot.net> writes:

Toggle quote (17 lines)
> * doc/ref/data-rep.texi: Document unspecified?.
> ---
> doc/ref/data-rep.texi | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/doc/ref/data-rep.texi b/doc/ref/data-rep.texi
> index bb7f74afe..f179a3560 100644
> --- a/doc/ref/data-rep.texi
> +++ b/doc/ref/data-rep.texi
> @@ -470,6 +470,9 @@ check to see if @var{x} is @code{SCM_UNBOUND}. History will not be kind
> to us.
> @end deftypefn
>
> +@deffn {Scheme Procedure} unspecified? x
> +Return @code{#t} if @var{x} is unspecified, else @code{#f}.
> +@end deffn

I'm not sure it's a good idea to document this procedure as part of our
public API, but if we were to document it, it would require a more
informative description.

It's nonsensical to ask whether a given object is "unspecified". When
the Scheme standards say that the result of a computation is an
unspecified value, that means that *any* Scheme object could be
returned.

In Guile, for historical reasons, we usually return a particular object
SCM_UNSPECIFIED (a.k.a. *unspecified*) in cases where the specification
says that the result is unspecified. However, we make no promises that
this will remain the case in future versions of Guile.

The number of legitimate uses for 'unspecified?' is extremely small. In
fact, I can think of only one: when a REPL prints the result of a user's
computation, it is nice to avoid printing "*unspecified*" and instead
print nothing in that case.

In almost every other case, use of 'unspecified?' implies an assumption
that it's possible to detect when a value is an "unspecified" value,
when in fact that is fundamentally impossible.

What do you think?

Mark
A
A
Arun Isaac wrote on 21 Jan 2018 19:22
(name . Mark H Weaver)(address . mhw@netris.org)(address . 30145-done@debbugs.gnu.org)
cu7po63ysvj.fsf@systemreboot.net
Mark H Weaver <mhw@netris.org> writes:

About undefined?: That was a typo. I mentioned that in a later message.

Toggle quote (21 lines)
> It's nonsensical to ask whether a given object is "unspecified". When
> the Scheme standards say that the result of a computation is an
> unspecified value, that means that *any* Scheme object could be
> returned.
>
> In Guile, for historical reasons, we usually return a particular object
> SCM_UNSPECIFIED (a.k.a. *unspecified*) in cases where the specification
> says that the result is unspecified. However, we make no promises that
> this will remain the case in future versions of Guile.
>
> The number of legitimate uses for 'unspecified?' is extremely small. In
> fact, I can think of only one: when a REPL prints the result of a user's
> computation, it is nice to avoid printing "*unspecified*" and instead
> print nothing in that case.
>
> In almost every other case, use of 'unspecified?' implies an assumption
> that it's possible to detect when a value is an "unspecified" value,
> when in fact that is fundamentally impossible.
>
> What do you think?

I agree. I didn't put very much thought into the matter before I sent
the patch. I needed unspecified? for a patch to GNU Guix. I found the
info documentation missing for unspecified? and thought I'll write
it. Later, it turned out unspecified? was not necessary for the Guix
patch after all. But, I had already documented unspecified?. So, I sent
it here.

Anyways, I'll close this bug report.
Closed
?