[comp.lang.modula2] Ident vs Designator

ROSS@UCF1VM.BITNET (Bri) (07/01/90)

I would like to know the reasoning behind the requirement
of using an Ident instead of a Designator as the index variable
in a FOR statement.

I do not see why the use of Designators is not allowed.

FOR record.integer := 1 TO 10 DO
END; (* FOR *)

Such a case causes no problems for compilers or loaders and seems quite
logical.

Anyone have any comments or reasons as to why such a restriction/definition
was written into the language?


Bri

Brian Ross

ROSS@UCF1VM.BITNET
ROSS@UCFLAN.CC.UCF.EDU

pf@artcom0.artcom.north.de (Peter Funk) (07/02/90)

ROSS@UCF1VM.BITNET (Bri) writes:

br> I would like to know the reasoning behind the requirement
br> of using an Ident instead of a Designator as the index variable
br> in a FOR statement.

br> I do not see why the use of Designators is not allowed.

br> FOR record.integer := 1 TO 10 DO
br> END; (* FOR *)

br> Such a case causes no problems for compilers or loaders and seems quite
br> logical.

br> Anyone have any comments or reasons as to why such a restriction/definition
br> was written into the language?

Consider the following Record :

	TYPE example = RECORD one : [ 0 .. 15 ];
			      two : [ 0 .. 4095 ];
		       END;

A compiler (-writer) might consider to implement this as one 16-Bit Word.
If it would be allowed to use one of the record components as a for-loop 
index variable, this would introduce many difficulties into the 
loop-control code to be generated.
-- 
Peter Funk \\ ArtCom GmbH, Schwachhauser Heerstr. 78, D-2800 Bremen 1
Work at home: Oldenburger Str.86, D-2875 Ganderkesee 1 /+49 4222 6018 (8am-6pm)
>> PLEASE Don't send BIG mails (oversea) ! I've to pay for it : $0.3/kB
   Don't use the bang path of this news article for mails (They will bounce).
   Only the address 'pf@artcom0.artcom.north.de' will work. Thank You ! <<

Pat.Terry@p101.f4.n494.z5.fidonet.org (Pat Terry) (07/04/90)

In Message-ID: <INFO-M2%90070101452673@UCF1VM.BITNET> you write

 > I do not see why the use of Designators is not allowed.
 > 
 > FOR record.integer := 1 TO 10 DO
 > END; (* FOR *)
 > 

   VAR
     Funny : RECORD 
               CASE J : BOOLEAN OF
                 TRUE : I : CARDINAL;
                 FALSE : (* empty *)
               END
             END;

   BEGIN
     Funny.J := TRUE;
     FOR Funny.I := 1 TO 4 DO
        Funny.J := FALSE;
        (* now what *)
     END

FOR loop variables are supposed to be as simple as possible to stop them getting
messed up in any one of the dozens of perverted ways one might think of doing   
so.

It would be interesting to see a really good example of a FOR loop where one
wanted something other than a simple variable.

  




--  
uucp: uunet!m2xenix!puddle!5!494!4.101!Pat.Terry
Internet: Pat.Terry@p101.f4.n494.z5.fidonet.org