[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fast R6RS div/mod; improved extensibility of numerics
From: |
Andy Wingo |
Subject: |
Re: [PATCH] Fast R6RS div/mod; improved extensibility of numerics |
Date: |
Mon, 31 Jan 2011 21:16:03 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
On Mon 31 Jan 2011 18:35, Mark H Weaver <address@hidden> writes:
> Andy Wingo <address@hidden> writes:
>>> The last patch might be slightly controversial. Although it does not
>>> make `integer-expt' a generic function, nonetheless it can now
>>> exponentiate _any_ scheme object that can be multiplied using `*'.
>>
>> To me this is fine, in principle; but I wonder about causing `(expt #t
>> 0)' to produce 1. It seems that in any case the range of the output
>> should be continuous -- i.e. if (expt <my-matrix> 1) produces a matrix,
>> and (expt <my-matrix> n) for n > 1 makes a matrix, then (expt
>> <my-matrix> 0) should also produce a matrix. Or no?
>
> When using generic arithmetic operators, there's no way to return
> objects of the correct type in all corner cases like this.
I did apply it, but it made the test cases start to fail, because
numbers.test is loaded after ecmascript.test, and:
scheme@(guile-user)> ,L ecmascript
Happy hacking with ECMAScript! To switch back, type `,L scheme'.
ecmascript@(guile-user)> true * true;
$1 = 1
ecmascript@(guile-user)> ,L scheme
Happy hacking with Scheme! To switch back, type `,L ecmascript'.
scheme@(guile-user)> (* #t #t)
$2 = 1
I think that's the thing, anyway. It just sounds really squirrelly.
Could you not extend `expt' or `integer-expt' instead?
Andy
--
http://wingolog.org/