[net.lang.mod2] Record assignments in Modula-2

papke@dicomed.UUCP (Kurt Papke) (03/19/85)

Question: (possibly very naive!!) does Modula-2 allow assignments of records ?
Wirth's book explicity allows assignment of array variables (see middle of pg
34), but is unclear (to me) whether assignments of record variables are legal.
Example:

	TYPE rec = RECORD x1, x2 : integer END;
	VAR rec1, rec2 : rec;
	BEGIN
		rec1 := rec2
	END.

Does anyone out there know what it should be ??  Does anyone have any
experience as to which compilers allow, disallow, or croak on such an
expression ??

If the response warrants, I will post the record (ugh!) to the net.

kc@rna.UUCP (Kaare Christian) (03/22/85)

> Question: (possibly very naive!!) does Modula-2 allow assignments of records ?

Yes. I couldn't find a direct citation, but I've used the feature on
several compilers.

The answer can probably be inferred from section 9.1 of the Report. It says
"Operand types are said to be assignment compatible, if either they are
compatible or ... " Since any type is compatible with itself (another claim
without a solid citation that I can find) it seems all types can
be assigned values. I've made a table of all of the Modula-2 data types
and their allowable operations.  Assignment is the only universal operation.

Kaare Christian
cmcl2!rna!kc