[M3devel] [Fwd: Re: A nonnative 64-bit language proposal]

Tony Hosking hosking at cs.purdue.edu
Fri Jul 20 22:48:34 CEST 2007


I think I am coming around to Rodney's position.  We should consider  
INTEGER and LONGINT assignable under the current rules for  
subranges.  Thus, INTEGER := LONGINT will cause a range check (and  
underlying conversion of the integer value from BITSIZE(LONGINT) to  
BITSIZE(INTEGER)), whereas LONGINT := INTEGER will need not check  
(though the conversion will be necessary to extend sign as  
expected).  I believe this functionality can easily be implemented in  
the current compiler.

Also, I am willing to allow indexing of arrays using LONGINT-based  
ordinals for the index type.  The usual restrictions on array size  
will obtain, and zero-based array indexes will be computed into  
integer offsets.  Thus, for an array indexed [minL..maxL] where minL  
and maxL have base type LONGINT, the offset will be computed as:

	index - minL

and converted to an INTEGER value to index the array.  Because of the  
sizing restriction, index - minL must be expressible as an INTEGER.   
Here are my revised notes:

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: longint.txt
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20070720/3bbb0bd8/attachment-0005.txt>
-------------- next part --------------

On Jul 19, 2007, at 6:04 PM, Rodney M. Bates wrote:

>
>
> Tony Hosking wrote:
>> On Jul 19, 2007, at 4:33 PM, Darko wrote:
>>> I actually favour a implicit conversion, which for this  
>>> particular  case I think would be consistent with existing M3  
>>> behaviour.
>> There is no implicit conversion for floats.  The danger with  
>> implicit  conversion for integers is that it would not be  
>> portable: you would  get different behavior on different machines  
>> for the same code.   Better to make the conversion explicit so  
>> that programmers are  prepared for the range check to fail.
>
> But is this argument any stronger for requiring explicit conversions
> for INTEGER/LONGINT assignments than for assigning to subranges?
> Many assignments in the language now, without any type conversion,
> admit the possibility of RT range errors.  And these can be dependent
> on the size of INTEGER too.  Consider:
>
>   VAR V : [ 0 .. 65535 ] ;
>   VAR I : CARDINAL ;
>   ...
>   V := I DIV 2 ;
>
> I think for portability, the principle that the static semantics  
> should be
> the same for all sizes of INTEGER (and LONGINT too) is as much as  
> we can
> hope for.  Certainly, there are already countless ways the integer  
> size can
> change the dynamic semantics of a program.
>
>
> -- 
> -------------------------------------------------------------
> Rodney M. Bates, retired assistant professor
> Dept. of Computer Science, Wichita State University
> Wichita, KS 67260-0083
> 316-978-3922
> rodney.bates at wichita.edu



More information about the M3devel mailing list