From: Andy Wingo <wingo@pobox.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-devel@gnu.org
Subject: Re: [PATCH] First batch of numerics changes
Date: Sat, 29 Jan 2011 12:29:09 +0100 [thread overview]
Message-ID: <m362t854oq.fsf@unquote.localdomain> (raw)
In-Reply-To: <871v3w4lrk.fsf@yeeloong.netris.org> (Mark H. Weaver's message of "Fri, 28 Jan 2011 19:05:35 -0500")
On Sat 29 Jan 2011 01:05, Mark H Weaver <mhw@netris.org> writes:
> Andy Wingo <wingo@pobox.com> writes:
>> I think that certainly when it comes to numbers, strictness is good. In
>> particular the r6rs says:
>>
>> (zero? z) procedure
>> (positive? x) procedure
>> (negative? x) procedure
>> (odd? n) procedure
>> (even? n) procedure
>> (finite? x) procedure
>> (infinite? x) procedure
>> (nan? x) procedure
>>
>> The name of the argument indicates the type, as noted earlier in the
>> report. `z' is a complex number, `x' is a real, and `n' is an integer.
>> It is an error to pass a non-integer to even?. It is also an error to
>> pass a non-real to infinite?.
>
> Are you reading the final version of R6RS, or a draft? The above
> paragraph is not present at:
>
> http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html
It is hidden here:
http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-9.html#node_sec_6.2
For succinctness, the report follows the convention that if a parameter
name is also the name of a type, then the corresponding argument must be
of the named type. For example, the header line for vector-ref given
above dictates that the first argument to vector-ref must be a
vector. The following naming conventions imply type restrictions:
obj any object
z complex number object
x real number object
y real number object
q rational number object
n integer object
k exact non-negative integer object
bool boolean (#f or #t)
octet exact integer object in {0, ..., 255}
byte exact integer object in { - 128, ..., 127}
char character (see section 11.11)
pair pair (see section 11.9)
vector vector (see section 11.13)
string string (see section 11.12)
condition condition (see library section on “Conditions”)
bytevector bytevector (see library chapter on “Bytevectors”)
proc procedure (see section 1.6)
Other type restrictions are expressed through parameter-naming
conventions that are described in specific chapters. For example,
library chapter on “Arithmetic” uses a number of special parameter
variables for the various subsets of the numbers.
With the listed type restrictions, it is the programmer’s responsibility
to ensure that the corresponding argument is of the specified type. It
is the implementation’s responsibility to check for that type.
> However, I strongly believe that finite?, infinite?, and nan? should be
> applicable to non-real complex numbers. They would clearly be useful as
> such, otherwise those working with complex numbers will have to
> reimplement them.
Dunno. Is inf? true if either of the components of a complex number are
inf? If that is the case, as you had it, shouldn't finite? be true if
either component is finite?
Users of complex numbers have to choose what they mean when they ask
inf? of a number. I think that's the intention of the report.
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-01-29 11:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 16:32 [PATCH] First batch of numerics changes Mark H Weaver
2011-01-26 18:07 ` Mark H Weaver
2011-01-26 22:46 ` Mark H Weaver
2011-01-27 22:06 ` Mark H Weaver
2011-01-28 12:19 ` Andy Wingo
2011-01-29 0:05 ` Mark H Weaver
2011-01-29 11:29 ` Andy Wingo [this message]
2011-01-27 22:32 ` Mark H Weaver
2011-01-28 13:46 ` Andy Wingo
2011-01-28 14:44 ` Noah Lavine
2011-01-28 15:55 ` Andy Wingo
2011-01-29 8:20 ` Mark H Weaver
2011-01-29 17:42 ` Andy Wingo
2011-01-29 20:20 ` Mark H Weaver
2011-01-30 11:48 ` Andy Wingo
2011-01-29 17:50 ` Andy Wingo
2011-01-29 20:36 ` Mark H Weaver
2011-01-29 22:24 ` Mark H Weaver
2011-01-30 6:02 ` Commentary: R6RS div0-and-mod0 vs Taylor's `round/' Mark H Weaver
2011-01-30 11:50 ` [PATCH] First batch of numerics changes Andy Wingo
2011-01-30 12:12 ` Andy Wingo
2011-01-30 16:33 ` Mark H Weaver
2011-01-28 11:41 ` Andy Wingo
2011-01-28 23:36 ` Mark H Weaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m362t854oq.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=mhw@netris.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).