[M3devel] unused warning isn't transitive

Rodney M. Bates rodney.m.bates at cox.net
Thu Jul 30 15:23:03 CEST 2009


Jay K wrote:
> 1) I was guessing inappropriately when I added BITS 32. I'll remove it.
>   

I didn't realize you had recently added this.  Wasn't there something
similar from earlier?

> 2) I understand the need to have exactly sized types, certainly. I don't understand Modula-3's features here.
>   

Modula-3 packed types are often not well understood.  The
language is more-abstract/higher-level than many languages,
and this is unfamiliar.   Some things that seem to be frequently
missed:

1)  Packed types have no effect on the set of values representable.
     That comes strictly from the base type, which is the abstract part. 
     Packed types can only force the compiler neither to allocate padding
     nor more bits than needed by the value set of the base type.

2) Packed types have an effect only when used as the type of a field
    of a record or object or as the type of elements of an array. 
    Declaring a whole variable of a packed type doesn't do anything
    different from declaring it to have the base type. (Except, there
    are some losses to assignability, e.g., you can't directly assign
    between two different packed types that have the same base
    type.)
    
>  
>  
>  - Jay
>
>
>
>
> ----------------------------------------
>   
>> Date: Wed, 29 Jul 2009 20:48:36 -0500
>> From: rodney.m.bates at cox.net
>> To: m3devel at elegosoft.com
>> Subject: Re: [M3devel] unused warning isn't transitive
>>
>> There is more wrong with this code than unused warnings.
>> From 2.2.5 Packed types: "variables of type T that occur in
>> records, objects, or arrays will occupy exactly n bits and be
>> packed adjacent to the preceding field or element".
>> (here, type T is BITS n FOR Base).
>>
>> The packed type has no effect when variables of T are not
>> so enclosed. And the Int32Rec is nowhere enclosed in a
>> record, object, or array. Perhaps the BITS 32 FOR should be
>> moved inside the record and applied to the type of field v?
>>
>>
>> Jay K wrote:
>>     
>>> TYPE Int32Rec = BITS 32 FOR RECORD v : Swap.Int32 END;
>>> (* We need v to be inside a record. Otherwise, the language would allow
>>> a compiler to actually allocate more than the BITS 32 for a value of
>>> type Swap.Int32.
>>> *)
>>> VAR Int32RecVar : Int32Rec;
>>> VAR CheckInt32 : [ 0 .. 0 ] := ADR(Int32RecVar) - ADR(Int32RecVar.v);
>>>
>>>
>>> Compiler complains that CheckInt32 isn't used.
>>> It should also perhaps mention Int32RecVar therefore.
>>>
>>>
>>> - Jay
>>>
>>>       




More information about the M3devel mailing list