comp.lang.ada
 help / color / mirror / Atom feed
From: <MARTIN%SCRANTON.BITNET@vma.cc.cmu.edu>
Subject: RE: WITH in Pascal
Date: Wed, 24 Apr 91 09:12 EST	[thread overview]
Message-ID: <9104241316.AA23057@ajpo.sei.cmu.edu> (raw)

Eric Gustafson writes:

>     In the process of translating Pascal, Turbo 5.5, code to Ada, Meridan, I
>and the other members of my class group found that there was no equalivent to
>the pascal WITH statement.  After some discussion we could not think of any
>reason why the facility would cause *bad* programming practices.

The WITH allows the variable name to be significantly separated from the
operations done to its fields.  This is a bad programming practice.

>... what was the method used .. in Ada.

the aggregate assignment (ref: Cohen _Ada as a Second Language_, pp 206..):

>Example ( In Pascal ):
>..
>Type
>  PersonRec  = Record
>                 Name : String;
>                 Age  : Integer;
>                 ID   : Integer;
>               end; { PersonRec }
>..
>Var
>  Person     : PersonRec;
>..
>  WITH Person do
>  begin
>    Name := 'Asdfg';
>    Age  := 24;
>    ID   := 123930;
>  end; { with person }
>..

In Ada:
Person := (
        Name => "Asdfg",
        Age => 24,
        ID => 123930);

                ....Dennis Martin

                 reply	other threads:[~1991-04-24 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox