[M3devel] null type?

mika at async.caltech.edu mika at async.caltech.edu
Thu Apr 25 04:53:13 CEST 2013


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