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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: SPARK 2014 and protected objects Date: Tue, 30 Aug 2016 19:42:18 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="90a7515de723fda2443060f3e878f4b0"; logging-data="6985"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qfsvPkGiI2JEH1LRCGs9rPqnvol8sf3E=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:wev7KoqMk61btOjHxx5rEmwwtPE= sha1:LDBoGGODV7XyaL+qnbJb/HeH/hE= Xref: news.eternal-september.org comp.lang.ada:31648 Date: 2016-08-30T19:42:18+01:00 List-Id: Simon Wright writes: > What is a non-external state? This version proves OK. Note the (State with External). I _think_ that Protected_Value and Impl's spec, being Part_Of State, have to be in the same declarative region (i.e. not the body). package PO with Spark_Mode => On, Abstract_State => (State with External), Initializes => State is procedure Set (Value : Integer) with Depends => (State =>+ Value); procedure Get (Value : out Integer) with Depends => (State => State, Value => State); private Protected_Value : Integer := 0 with Volatile, Part_Of => State; protected Impl with Part_Of => State is procedure Set (Value : Integer) with Depends => (Impl => Impl, Protected_Value => Value); procedure Get (Value : out Integer) with Depends => (Impl => Impl, Protected_Value => Protected_Value, Value => Protected_Value); end Impl; end PO; package body PO with Spark_Mode => On, Refined_State => (State => (Protected_Value, Impl)) is procedure Set (Value : Integer) is begin Impl.Set (Value); end Set; procedure Get (Value : out Integer) is begin Impl.Get (Value); end Get; protected body Impl is procedure Set (Value : Integer) is begin Protected_Value := Value; end Set; procedure Get (Value : out Integer) is begin Value := Protected_Value; end Get; end Impl; end PO;