unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Unspecified?
@ 2008-11-14 10:38 Maciek Godek
  2008-11-14 16:44 ` Unspecified? Andy Wingo
  2008-11-14 21:20 ` Unspecified? Ludovic Courtès
  0 siblings, 2 replies; 5+ messages in thread
From: Maciek Godek @ 2008-11-14 10:38 UTC (permalink / raw)
  To: guile-user

Hey all yoh!
Is there any "official" way to check whether or not
a function returns a (specified) value?

As I ran into the problem, I quickly came with a workaround:
(define unspecified (if #f #t))
which allows to define the most basic predicates:
(define (unspecified? x) (eq? x unspecified))
(define (specified? x) (not (unspecified? x)))

but I find it kinda surprising that these are not available
by default in the system.

Best regards
M.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unspecified?
  2008-11-14 10:38 Unspecified? Maciek Godek
@ 2008-11-14 16:44 ` Andy Wingo
  2008-11-15 15:02   ` Unspecified? Jon Wilson
  2008-11-14 21:20 ` Unspecified? Ludovic Courtès
  1 sibling, 1 reply; 5+ messages in thread
From: Andy Wingo @ 2008-11-14 16:44 UTC (permalink / raw)
  To: Maciek Godek; +Cc: guile-user

Hey Maciek,

On Fri 14 Nov 2008 11:38, "Maciek Godek" <pstrychuj@gmail.com> writes:

> Hey all yoh!
> Is there any "official" way to check whether or not
> a function returns a (specified) value?

Yes and no; R5RS has this to say:

    If the value of an expression is said to be "unspecified," then the
    expression must evaluate to some object without signalling an error,
    but the value depends on the implementation; this report explicitly
    does not say what value should be returned.

In practice, in all situations in which R5RS defines a result as
unspecified, those values will be `eq?' to `(if #f #f)'.

> but I find it kinda surprising that these are not available
> by default in the system.

Odd, yes. We inherit this oddity from Scheme.

Andy
-- 
http://wingolog.org/




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unspecified?
  2008-11-14 10:38 Unspecified? Maciek Godek
  2008-11-14 16:44 ` Unspecified? Andy Wingo
@ 2008-11-14 21:20 ` Ludovic Courtès
  2008-11-14 22:22   ` Unspecified? Maciek Godek
  1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2008-11-14 21:20 UTC (permalink / raw)
  To: guile-user

Hello,

"Maciek Godek" <pstrychuj@gmail.com> writes:

> As I ran into the problem, I quickly came with a workaround:
> (define unspecified (if #f #t))
> which allows to define the most basic predicates:
> (define (unspecified? x) (eq? x unspecified))
> (define (specified? x) (not (unspecified? x)))
>
> but I find it kinda surprising that these are not available
> by default in the system.

They are not documented because they are not... specified.  :-)

Actually, Guile defines `*unspecified*' and also provides
`unspecified?', so all you need to define is `specified?'.

Thanks,
Ludo'.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unspecified?
  2008-11-14 21:20 ` Unspecified? Ludovic Courtès
@ 2008-11-14 22:22   ` Maciek Godek
  0 siblings, 0 replies; 5+ messages in thread
From: Maciek Godek @ 2008-11-14 22:22 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-user

>> but I find it kinda surprising that these are not available
>> by default in the system.
>
> They are not documented because they are not... specified.  :-)

Yeah, I get that :D

> Actually, Guile defines `*unspecified*' and also provides
> `unspecified?', so all you need to define is `specified?'.

OK, I didn't know that
(I've been looking for it in the documentation -- especially
for the "unspecified?", but I didn't even bother to check if
the function is available)

Thanks
M.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Unspecified?
  2008-11-14 16:44 ` Unspecified? Andy Wingo
@ 2008-11-15 15:02   ` Jon Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Wilson @ 2008-11-15 15:02 UTC (permalink / raw)
  To: guile-user

Andy Wingo wrote:
> Yes and no; R5RS has this to say:
> 
>     If the value of an expression is said to be "unspecified," then the
>     expression must evaluate to some object without signalling an error,
>     but the value depends on the implementation; this report explicitly
>     does not say what value should be returned.
> 
> In practice, in all situations in which R5RS defines a result as
> unspecified, those values will be `eq?' to `(if #f #f)'.
> 
For Guile, yes.  But an R5RS conforming Scheme might well return a 
unique value for every expression whose value is unspecified.  (display 
"unspecified") might return 5, or "unspecified", or a pink and white 
unicorn whale.  But Guile is kind to us, and always returns the same 
value as is returned by (if #f #f), namely, *unspecified*.

I know you already know all this, Andy.  I'm just running my mouth off.
Regards,
Jon




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-15 15:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-14 10:38 Unspecified? Maciek Godek
2008-11-14 16:44 ` Unspecified? Andy Wingo
2008-11-15 15:02   ` Unspecified? Jon Wilson
2008-11-14 21:20 ` Unspecified? Ludovic Courtès
2008-11-14 22:22   ` Unspecified? Maciek Godek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).