[M3devel] null type?

Darko darko at darko.org
Thu Apr 25 05:11:17 CEST 2013


Probably not a good idea to make it illegal for backwards compatibility if you really think it's going to break things, so perhaps issue a warning instead. But besides providing a type for NIL it doesn't serve much purpose and I can't see anything being lost by outlawing it, eliminating the confusion with REFANY might be gained.

Just because it's a valid bit of code doesn't mean it's not a bug. Looking at the code you can reasonably assume the author thought NIL was of type REFANY. It's a useless declaration unless it's trying to make some sort of point by being useless. It's a declaration to pass in one possible value which it's already assigned and which you can't change. 


On Apr 24, 2013, at 7:53 PM, mika at async.caltech.edu wrote:

> Darko writes:
>> 
>> --Apple-Mail-2--196294281
>> Content-Transfer-Encoding: quoted-printable
>> Content-Type: text/plain;
>> 	charset=us-ascii
>> 
>> I think the correct approach is to treat a variable declaration with a =
>> type NULL as an error. The correspondence to C would be void, but just =
>> void, not void*.  What is the representation of the declaration "void =
>> x"? I'm guessing C doesn't allow that.
> 
> It's not an error since there is precisely one legal value for such a variable,
> namely, NIL.  That value can be inferred from the type without inspecting the
> variable.
> 
> If you make it illegal to declare variables of type NULL you may have to go
> back and change various code generators that depend on it.
> 
> There are types that are truly empty in Modula-3, and it is illegal to
> declare variables of those types (but not illegal to declare those types
> or to use them to construct other types), e.g.,
> 
> CONST
>  A = 3;
>  B = 1;
> 
> TYPE
>  T = [A..B];
> 
> VAR
>  t : T; (* static error *)
> 
> TYPE
>  A = ARRAY T OF X; (* not an error *)
> 
> etc.




More information about the M3devel mailing list