[net.micro] Turbo PASCAL quirk?

cem@intelca.UUCP (Chuck McManis) (02/20/85)

In writing a formatter for Turbo PASCAL programs I came upon the following
feature/Bug and am not sure if it is "standard" or not. When the following
code is executed (With the given declarations)

Type 
  Ident_Ptr = ^Ident;
  Ident = Record
            Name       : String[127];
            ID_Type    : Ident_Type;
            References : Line_Ref;
            Nxt_Ident  : Ident_Ptr;
          End;
Var
  Sym_List : Ident_Ptr;

...

  With Sym_List^ Do
  Begin
    While Name <> '' do
    Begin
      Writeln(Name);
      Print_References(References);
      Sym_List := Nxt_Ident;
    End; (* While *)
  End; (* With *) 

What happens is that the line Sym_List := Nxt_Ident has no effect since
the With statement seems to lock you into the VALUE of the Sym_List 
pointer when you enter the With statement. Is this standard PASCAL?
I assumed, obviously incorrectly, that this code is equivalent to the
same code without the With and with all of the record fields prefixed 
with Sym_List^. 

BTW, I am using Turbo PASCAL V2.0 on a CP/M 80 machine, I have not had
the opportunity to try it on a MS-DOS machine yet.

--Chuck
-- 
                                            - - - D I S C L A I M E R - - - 
{ihnp4,fortune}!dual\                     All opinions expressed herein are my
        {qantel,idi}-> !intelca!cem       own and not those of my employer, my
 {ucbvax,hao}!hplabs/                     friends, or my avocado plant. :-}

campbell%DECWRL@maynard.UUCP (02/23/85)

The assignment to the record pointer is illegal, according to section
9.2.4 of the Pascal Report.  It's probably a bug in Turbo that it
doesn't issue a compilation error.

- Larry Campbell

Pucc-HPucc-I:@CS-Mordred.UUCP (02/23/85)

>  What happens is that the line Sym_List := Nxt_Ident has no effect since
>  the With statement seems to lock you into the VALUE of the Sym_List 
>  pointer when you enter the With statement. Is this standard PASCAL?
>  I assumed, obviously incorrectly, that this code is equivalent to the
>  same code without the With and with all of the record fields prefixed 
>  with Sym_List^. 

The implementation is correct.  According to the American Pascal Standard,

	The record-variable shall be accessed before the statement
	of the with-statement is executed, and that access shall
	establish a reference to the variable during the entire
	execution of the statement of the with-statement.

The line Sym_List := Nxt_Ident does indeed have an effect (it changes
the value of Sym_List), but it does not affect the record-variable
access which is effective for the entire duration of the with-statement.

By the way, underscores in identifiers are not standard Pascal.

>  Type 
>    Ident_Ptr = ^Ident;
>    Ident = Record
>              Name       : String[127];
>              ID_Type    : Ident_Type;
>              References : Line_Ref;
>              Nxt_Ident  : Ident_Ptr;
>            End;
>  Var
>    Sym_List : Ident_Ptr;
>  
>  ...
>  
>    With Sym_List^ Do
>    Begin
>      While Name <> '' do
>      Begin
>        Writeln(Name);
>        Print_References(References);
>        Sym_List := Nxt_Ident;
>      End; (* While *)
>    End; (* With *) 
-- 
Dave Seaman			 ..!pur-ee!pucc-i:ags