|
Home
>
3. concept
>
3.3 types and classes
>
3.3.1 types
>
3.3.1.3 limited types
>
3.3.1.3.1 the 'limited' operation: Grasp the various integer meanings.
|
Previous
Next
|
|
|
|
|
|
Jeff Dalton
|
Programmers will want machine-precisions arithmetic (or near it -- 29
bits might work) because they feel it will be faster, use less storage,
and be more likely to use "immediate" representations that don't
require heap allocation.That's not really the same as "total control".
Now, the problem is that if someone wants this, the class name will
be different in different implementations. So, ok, they start renaming
using the module system so that they have a name they can use
everywhere. That's already work that shouldn't be necessary. But they
still can't write the same code for all implementations, if they want to
ocnvert small ints to bignums, because some implementations require
an explicit conversion. So they'll have to define a conversion function
that is sometimes the identity function.
|
|
Andrew
LM Shalit
|
The language currently handles this with the 'limited' operation, which
used to create new types. You can create a subtype of integer which
only includes the range of integers needed by your application. This
operation is portable.
Implementations will compile that limited integer subtype to the most
efficient machine representation available.
|
|
|
|
|
|