[armedbear-devel] long
dmiles@users.sourceforge.net
logicmoo at gmail.com
Wed Mar 17 04:34:52 UTC 2010
On Tue, Mar 16, 2010 at 8:57 AM, Alessio Stalla <alessiostalla at gmail.com> wrote:
> On Tue, Mar 16, 2010 at 4:41 PM, Alan Ruttenberg
> <alanruttenberg at gmail.com> wrote:
>>
>> On Mar 16, 2010, at 8:47 AM, dmiles at users.sourceforge.net wrote:
>>
>>> This is because ABCL:
>>> Fixnum => int
>>> Bignum => BigInteger
>>>
>>> ABCL does not have a 'long' type so it is normal workaround to produce
>>> a new 'long in your case.
>>>
>>> So depends who is desiring: There is no real spec other than Allegro
>>> http://www.franz.com/support/documentation/8.0/doc/jlinker.htm#data=types-conversions-3
>>> But Allegro spec here is lossy..
>>> (meaning if you went from a Lisp Bignum->Java->Lisp.. the number would
>>> scaled back to Long.MAX_VALUE) So their spec is even more
>>> undesirable.
>>
>> Agreed.
>>
>>> It would be possible that when the Bignum is within normal java long
>>> range the javaInstance() could return a java.lang.Long instead.
>>>
>>> Does everyone think this would be better behavior than current ABCL and Allegro?
>>
>> I'm thinking it would be. However, given that there is a workaround I wouldn't put it as high priority - more as a cleanup.
>
> I think it would be, too. It's also arguably more efficient to
> manipulate Longs than BigIntegers. However, doing so requires that we
> also implement promotion, I mean, if a calculation result overflows
> longs it should be automatically upgraded to big integer. Java does
> not do anything like that, so I believe we must do it ourselves.
>
> Alessio
My suggestion above was for an easy work around is something like this
in Bignum.java
@Override
public Object javaInstance()
{
long lng = value.longValue();
if (value.equals(BigInteger.valueOf(lng))) return Long.valueOf(lng);
return value;
}
The java lisp I work on has bignum types that get demoted and promoted
as needed.
SubLFixnum -> int
SubLLongBignum -> long
SubLBigIntBignum -> BigInteger
The code is at http://larkc.svn.sourceforge.net/viewvc/larkc/branches/LarKC_CommonLisp_Extensions/platform/src/com/cyc/tool/subl/jrtl/nativeCode/type/number/
>
>> -Alan
>>
>>>
>>>
>>> On Mon, Mar 15, 2010 at 11:47 PM, Alan Ruttenberg
>>> <alanruttenberg at gmail.com> wrote:
>>>>
>>>> Am I right to observe that abcl coerces any number > fixnum size to bigint?
>>>> I'm having trouble calling a java method that takes a long. I seem to
>>>> have worked around it calling the method with (new 'long
>>>> "9223372036854775807") rather than 9223372036854775807 .
>>>>
>>>> Is this the desired behavior?
>>>>
>>>> -Alan
>>>>
>>>> _______________________________________________
>>>> armedbear-devel mailing list
>>>> armedbear-devel at common-lisp.net
>>>> http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>>
>>
>> _______________________________________________
>> armedbear-devel mailing list
>> armedbear-devel at common-lisp.net
>> http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>>
>
More information about the armedbear-devel
mailing list