From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: SPARK - refactoring and refinement of own state
Date: Thu, 20 Aug 2009 01:44:54 -0700 (PDT)
Date: 2009-08-20T01:44:54-07:00 [thread overview]
Message-ID: <fde732b8-4926-4c8d-b797-60cfda085296@o35g2000vbi.googlegroups.com> (raw)
In-Reply-To: 88ecb7be-ade2-4d0b-8063-fa06d53be1e8@e34g2000vbm.googlegroups.com
On 20 Sie, 10:11, Rod Chapman <roderick.chap...@googlemail.com> wrote:
> In short: refinement only makes sense _within_ a single
> package, so you can only refine "onto" states which
> are logically hidden inside the package body - so either library
> level state in that package body, or states of private
> child packages of that package.
>
> So...no...you can't refine from one package body to the spec
> of another package, since this doesn't preserve
> the abstraction.
Or rather it doesn't preserve the information about state coupling.
Indeed, the grammar allows the inherit clause only in the package spec
(I was confused about that as well).
Just for completeness, the program after "refactoring" is:
-- greetings.ads:
with Spark_IO;
--# inherit Spark_IO;
package Greetings
is
procedure Say_Hello;
--# global in out Spark_IO.Outputs;
--# derives Spark_IO.Outputs from *;
end Greetings;
-- greetings.adb:
package body Greetings
is
procedure Say_Hello
is
begin
Spark_IO.Put_String (File => Spark_IO.Standard_Output,
Item => "Hello ",
Stop => 0);
end Say_Hello;
end Greetings;
-- hello.adb:
with Greetings;
--# inherit Greetings, Spark_IO;
--# main_program;
procedure Hello
--# global in out Spark_IO.Outputs;
--# derives Spark_IO.Outputs from *;
is
begin
Greetings.Say_Hello;
end Hello;
This shows that state coupling cannot be hidden (unless it is
hidden :-) ).
Thank you for explanations.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
Database Access Library for Ada: www.inspirel.com/soci-ada
prev parent reply other threads:[~2009-08-20 8:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-20 7:18 SPARK - refactoring and refinement of own state Maciej Sobczak
2009-08-20 7:37 ` Georg Bauhaus
2009-08-20 8:06 ` Rod Chapman
2009-08-20 8:11 ` Rod Chapman
2009-08-20 8:44 ` Maciej Sobczak [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox