From: eru.mt.luth.se!lunic!sunic!nobeltech!dawe@bloom-beacon.mit.edu (Daniel W
Subject: Re: Does the LRM permit parameter passing by reference?
Date: 11 Oct 92 16:20:45 GMT [thread overview]
Message-ID: <1992Oct11.162045.5904@nobeltech.se> (raw)
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.
next reply other threads:[~1992-10-11 16:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-10-11 16:20 eru.mt.luth.se!lunic!sunic!nobeltech!dawe [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-10-13 4:16 Does the LRM permit parameter passing by reference? Michael Feldman
1992-10-09 18:12 Michael Feldman
1992-10-09 14:11 Dan Rittersdorf
1992-10-09 2:38 Kevin Simonson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox