Ralf Hemmecke wrote:
> 
> >       import Character
> >       zero := ord(char("0")) pretend SI
> >
> >       parseInt(str : String) : I ==
> >            b := zero
> >            l   :=  # str  pretend SI
> >            s   :=  0      :: I
> >            ten :=  10     :: I
> >            for i in (1 .. l) repeat
> >                              dNum := (ord(qelt(str, i)) pretend SI) - b
> >                              s    := (ten*s) + dNum
> >            s
> 
> Waldek, I don't understand, why you have put "pretend SI" there. I 
> assume by SI you mean SingleInteger.
> 
>  From what I know, SingleInteger (or MachineInteger in libaldor) need 
> not (does not) have the same representation as Integer.
> 

Abstractly need not (and AFAIK does not in Aldor -> C compiler), but
currently in Lisp backend SingleInteger is a subset of Integer.


> That you code does what you expect, might have (at least) 3 reasons.
> 1) In the underlying lisp SingleInteger and Integer have the same 
> representation

Yes.

> 2) In SPAD SingleInteger and Integer have the same representation.
> 3) "pretend SI" is not simply a "pretend" but is actually doing some 
> casting operation, i.e. a runtime operation. (It's not in Aldor as far 
> as I know.)
> 
> I would have expected something like "::SingleInteger", since there is a 
> function "coerce: Integer->%" in SingleInteger.

I do not want 'coerce' because 'coerce' doing bound checking and
due to this currently can not be inlined.  I was thinking about
adding someting called 'qcoerce' which would be 'pretend' for
Lisp backend, but could be changed to something else with
different backend.  OTOH I am not sure if I want to support
backends where SingleInteger has different representation than
Integer -- at least currently I am thinking about keeping
common representation of Integer and SingleInteger in future
C backend.

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to