For Programmers: Free Programming Magazines  


Home > Archive > Scheme > August 2007 > Re: (even? 3.0) is the wrong type argument---how can I fix this?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: (even? 3.0) is the wrong type argument---how can I fix this?
William D Clinger

2007-08-27, 8:32 pm

notPythias wrote:
> I just got this error:
> ;ERROR: "tmp/09f9.scm": even?: Wrong type in arg1 3.0
> Does this mean even? expects an int and got a float?


It probably means the implementation of Scheme you are
using has a bug, although it might mean it does not even
claim to conform to the ANSI/IEEE/R5RS standards.

> By the way, this a learn-by-doing thing for me as I go through SICP, so
> I would prefer answers phrased in terms of general debugging tactics
> rather than specific instructions.


When posing a question of this kind, you should identify
the implementation of Scheme that you are using. (You
should also identify other relevant software and hardware.)

Along with the error message and your code, you should
give a simple test case that reproduces the error.

> In particular, is there any kind of function reference for R5RS Scheme?


Yes. See, for example, http://www.schemers.org/Documents/Standards/

Will

notPythias

2007-08-28, 10:12 pm

On 2007-08-27, William D Clinger <cesura17@yahoo.com> wrote:
> It probably means the implementation of Scheme you are
> using has a bug, although it might mean it does not even
> claim to conform to the ANSI/IEEE/R5RS standards.


apt-cache show scm says,
Scm conforms to Revised^5 Report on the Algorithmic Language Scheme and
the IEEE P1178 specification.

Actually, reading the R5RS standard you mentioned, I figured out that
even? expects an exact argument, and I was passing it an inexact number.

> When posing a question of this kind, you should identify
> the implementation of Scheme that you are using. (You
> should also identify other relevant software and hardware.)


My interpreter is scm 5e3, from the Debian Etch repositories. My
computer is a Thinkpad 570 (PII) with a 2.6.18 kernel. Is there anything
else I should mention?

> Along with the error message and your code, you should
> give a simple test case that reproduces the error.


I'll keep that in mind (although since I've already solved the problem,
I won't do it for this case).

Thanks!
-nP
Ray Dillinger

2007-08-29, 4:32 am

notPythias wrote:
> On 2007-08-27, William D Clinger <cesura17@yahoo.com> wrote:
>
>
>
> apt-cache show scm says,
> Scm conforms to Revised^5 Report on the Algorithmic Language Scheme and
> the IEEE P1178 specification.
>


But probably not in the same mode, since IEEE1178 did not
follow the R5RS changes and is still roughly equivalent to
R4RS. I should know, I was the coordinator of that
committee.

IEEE1178 scheme, in particular, has no multiple-value returns
and no winding continuations.

Bear

notPythias

2007-08-30, 8:34 pm

On 2007-08-29, Ray Dillinger <bear@sonic.net> wrote:
> But probably not in the same mode, since IEEE1178 did not
> follow the R5RS changes and is still roughly equivalent to
> R4RS. I should know, I was the coordinator of that
> committee.
>
> IEEE1178 scheme, in particular, has no multiple-value returns
> and no winding continuations.


Another reply assured me that R5RS even? accepts inexact arguments, so
maybe scm is trying to be P1178-compatible right now.

Of the two standards, which should I practice with?

-nP
Aubrey Jaffer

2007-08-30, 11:22 pm

notPythias <notPythias@gmail.com> writes:

> On 2007-08-27, William D Clinger <cesura17@yahoo.com> wrote:
>
> apt-cache show scm says,
> Scm conforms to Revised^5 Report on the Algorithmic Language Scheme and
> the IEEE P1178 specification.
>
> Actually, reading the R5RS standard you mentioned, I figured out that
> even? expects an exact argument, and I was passing it an inexact number.
>
>
> My interpreter is scm 5e3, from the Debian Etch repositories. My
> computer is a Thinkpad 570 (PII) with a 2.6.18 kernel. Is there anything
> else I should mention?


I have written a webpage describing "SCM Standards Conformance":

http://swiss.csail.mit.edu/~jaffer/SCM_CONFORMANCE

* SCM Standards Conformance

When compiled without floating-point number support, SCM conforms to:

* IEEE Standard 1178-1990,
IEEE Standard for the Scheme Programming Language,
ISBN 1-55937-125-0.

* William Clinger and Jonathan Rees, editors.
Revised4 Report on the Algorithmic Language Scheme
ACM Lisp Pointers 4(3), pages 1-55, 1991.

* Richard Kelsey and William Clinger and Jonathan Rees (Editors),
Revised5 Report on the Algorithmic Language Scheme
ACM SIGPLAN Notices 33(9), pages 26-76, 1998.

When compiled with floating-point number support, SCM's numerics are
instead described mostly by:

* Aubrey Jaffer,
SRFI 70: Numbers,
http://srfi.schemers.org/srfi-70/

* Aubrey Jaffer,
SRFI 94: Type-Restricted Numerical Functions,
http://srfi.schemers.org/srfi-94/

The incompatibilities with R5RS are:

* There are no exact (complex) non-real numbers (the only exact
numbers are integers).

* The procedures gcd, lcm, modulo, remainder, quotient, even?, and
odd? accept only exact integer arguments.

* Division by zero returns an infinity instead of erring.

* (/ 0 0) returns a NaN instead of erring.

* (log 0) returns an infinity instead of erring.

* (expt 0 -1) returns an infinity instead of erring.

* (* 0 (expt 0 -1)) returns a NaN instead of erring.

* The procedures number->string and string->number do not always
meet the inversion constraint "using the minimum number of
digits". I hope to see this get corrected. When SCM is compiled by
an optimizer (like gcc -O2) which generates code which uses 80.bit
intermediate floating-point values, violations of the inversion
constraint are rare in practice.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com