From: rod.chapman@praxis-cs.co.uk (Rod Chapman)
Subject: Re: [Spark] Converting Arrays
Date: 11 Mar 2003 02:14:19 -0800
Date: 2003-03-11T10:14:20+00:00 [thread overview]
Message-ID: <cf2c6063.0303110214.5c978575@posting.google.com> (raw)
In-Reply-To: slrnb6phge.1gd.lutz@taranis.iks-jena.de
"Out" mode unconstrained arrays are indeed an interesting part
of SPARK. They have the rather unusual property of having a value
which is not well-defined in such a body, but having attributes
(i.e. 'First and 'Last) which do have well-defined values.
A common trick in this case is to use a local,
hidden procedure to initialise the out parameter:
package body test is
procedure To_Fullpath (s : String; path : out Fullpath) is
procedure Init_Path;
--# global out Path;
--# derives Path from ;
is
--# hide Init_Path;
begin
Path := (others => ASCII.NUL); -- note Ada95 not SPARK!
end Init_Path; -- Warning 10 expected here - hidden body.
begin
Init_Path;
... -- as before...
end To_Fullpath;
end test;
This is a fine example of "moving the SPARK boundary" for perfectly
good reasons. You can even Inline such a local procedure if efficiency
is as issue.
- Rod, SPARK Team
next prev parent reply other threads:[~2003-03-11 10:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-10 17:06 [Spark] Converting Arrays Lutz Donnerhacke
2003-03-10 20:03 ` James S. Rogers
2003-03-10 22:33 ` Lutz Donnerhacke
2003-03-11 10:14 ` Rod Chapman [this message]
2003-03-11 10:51 ` Lutz Donnerhacke
2003-03-11 10:52 ` Lutz Donnerhacke
2003-03-11 20:46 ` JP Thornley
2003-03-12 8:43 ` Phil Thornley
2003-03-12 11:57 ` Lutz Donnerhacke
2003-03-12 18:46 ` JP Thornley
2003-03-13 10:14 ` Lutz Donnerhacke
2003-03-12 9:43 ` Rod Chapman
2003-03-12 10:15 ` Lutz Donnerhacke
-- strict thread matches above, loose matches on Subject: below --
2003-03-13 5:55 Grein, Christoph
2003-03-13 9:47 ` Peter Amey
2003-03-13 10:15 ` Lutz Donnerhacke
2003-03-21 15:05 ` Peter Amey
2003-03-21 15:17 ` Lutz Donnerhacke
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox