From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=BAYES_00,FROM_ADDR_WS autolearn=no autolearn_force=no version=3.4.5-pre1 Date: 11 Oct 92 16:20:45 GMT From: eru.mt.luth.se!lunic!sunic!nobeltech!dawe@bloom-beacon.mit.edu (Daniel W engelin) Subject: Re: Does the LRM permit parameter passing by reference? Message-ID: <1992Oct11.162045.5904@nobeltech.se> List-Id: Having read the debate on allowed parameter passing mechanisms, I would like to follow up with a related question. The LRM does (as far as I've understood) allow for an implementation to skip the "copy-back" of parameters in case an exception is raised preventing a normal return. What's the impact of this in the real world? Are any compilers using this optimization feature? I am especially interested in the following construct: package Smart_Error_Example type Status is (Ok, This_Error, That_Error); type Data is record -- Could also be private (normally) Current_Status : Status; Other_Stuff : ...... end record; procedure Do_Action ( D : in out Data); Any_Error : exception; end Smart_Error_Example; package body Smart_Error_Example is procedure Set_Status (The_Status : Status;On_Data : in out Data) is begin On_Data.Current_Status := The_Status; end Set_Status; procedure Do_Action (D: in out Data) is begin -- Do something useful if That_Error_Detected then Set_Status(That_Error, D); -- Set error info for later use raise Any_Error; end if; : end Do_Action; end Smart_Error_Example;--Unfortunately "erroneous" This error signaling scheme would be quite suitable for a lot of applications. It does probably work for most compilers. Does anyone know a system that fails on the above example? Can I prevent an optimizer from eliminating the assignment of the Current_Status-field by making Set_Status separate?? Thank you for considering these issues. Daniel Wengelin Systems Designer, NobelTech Systems, Naval Sector. Disclaimer: This article is on behalf of myself only.