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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Question on type invariants Date: Thu, 26 Jan 2017 09:38:19 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <65f79e53-a468-4b77-8ee1-440c26a09371@googlegroups.com> NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:33172 Date: 2017-01-26T09:38:19+01:00 List-Id: On 25/01/2017 09:38, reinkor wrote: > In principle I could mark A and S with a "last-modified-time-flag" > so I can update S when I find it necessary. This has similarities to unix > "make". Bad idea? It depends. There are many scenarios, e.g. transactions is to name one. What you have described looks like a lazy evaluation scheme. You keep track of applied changes ("expressions") and apply these changes on demand ("evaluate"). So long keeping commands is cheaper than applying them, it works fine. This schema is widely used for graphic contexts. Graphic operations do not have immediate effect, but cached until final rendering occurs, then the cache of commands is flushed. A continuation of the schema is having the object completely stateless. No value is kept only the commands to produce it. > I can program the whole thing and keep the concepts in my head, but > is t a natural "Ada way" to secure that S is up-to-date when used? There is no specific Ada's way. These are common considerations. > Is "type invariants" of any help? No. Invariant is a different thing. The idea is that the invariant is always true outside public calls, as Randy said, at the type's interface border. Since both updating and getting value are *public* operations they both must maintain the invariant. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de