From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ea40456edaea3d23 X-Google-Attributes: gid103376,public From: kilgallen@eisner.decus.org (Larry Kilgallen) Subject: Re: Pascal to Ada translator/ aflex,ayacc GNAT ports Date: 1996/12/02 Message-ID: <1996Dec2.093152.1@eisner>#1/1 X-Deja-AN: 201881071 x-nntp-posting-host: eisner.decus.org references: <57uki4INNkae@maz4.sma.ch> x-nntp-posting-user: KILGALLEN x-trace: 849537118/17699 organization: LJK Software newsgroups: comp.lang.ada Date: 1996-12-02T00:00:00+00:00 List-Id: In article <57uki4INNkae@maz4.sma.ch>, lga@sma.ch (Laurent Gasser) writes: > In the MacOs, you often have structures like a Rect which are > > Rect = record > top, bottom, right, left: integer; > end; > > You are typically using WITH when you are calculating with them. The intent > is to make the source easier to read, and only that. (Well, compiler might > write more efficent code as well.) > > my_rect : Rect; > > with my_rect do begin { may have a scope of many lines } > top := top - top_margin; > right := left + (3*(bottom - top)) div 4; > bottom := bottom - bot_margin; > end; > > In this case, the proposed solution would not help much. It would be > preferable to work as in C: no local block, and all the fields are written > in full. An extra local variable cannot do any better. > > my_rect.top := my_rect.top - top_margin; > my_rect.right := my_rect.left + (3*(my_rect.bottom - my_rect.top)) div 4; > my_rect.bottom := my_rect.bottom - bot_margin; > > This is the case every time the structured type is directly the type > of the variable at work. No array of, pointer to, or field in a record > of the structured type. The Ada renaming is quite effective when the > structured type is deeply nested in the variable call. Note that Macintosh Pascal compilers have often been constructed so as not to help the user regarding interaction between "with" statements and memory-moving toolbox calls. Thus if the "with" statement base calculation dereferences an unlocked handle (pointer to a pointer to data) no toolbox calls which might relocate heap should be made within the scope of that "with". Pascal code which ignores that problem might be hit only after translation to Ada, and for those trying to port code rather than point fingers (yes, it was bad Macintosh Pascal) a translator would be more valuable if it unrolled the problem "with" clauses (even if the best it could do was to unroll _all_ "with" clauses). Or can one rename something based on an aliased pointer ? Larry Kilgallen