With statement


With statements perform an action, while allowing the fields of specified record variables to be referencing using their field identifiers only. With statements include the following:


For example give the following type and variable.

     student = record
     name : string;
     address : string;
     grade : integer;

     s : student;

then the following with statement

   with s do
         name := 'John';
         address := 'main street';
         grade := 20;

is equivalent to

      s.name := 'John';
      s.address := 'main street';
      s.grade := 20;

Since some record types can contain other record types you can have nested with statements like the following:

   with record1 do
      with record2 do
        with record3 do

or you can use the following shorthand which does the same thing

  with record1, record2, record3 do


(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):

   with-statement = 'with' record-variable-list 'do' statement

   record-variable-list = record-variable { ';' record-variable }