comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Question on type invariants
Date: Thu, 26 Jan 2017 09:38:19 +0100
Date: 2017-01-26T09:38:19+01:00	[thread overview]
Message-ID: <o6cchr$u0q$1@gioia.aioe.org> (raw)
In-Reply-To: 65f79e53-a468-4b77-8ee1-440c26a09371@googlegroups.com

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

  parent reply	other threads:[~2017-01-26  8:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25  8:38 Question on type invariants reinkor
2017-01-25 22:06 ` Randy Brukardt
2017-01-26  4:31   ` reinkor
2017-01-26  4:32   ` reinkor
2017-01-26  8:38 ` Dmitry A. Kazakov [this message]
2017-01-27  9:20   ` reinkor
2017-01-27  9:47     ` Dmitry A. Kazakov
2017-01-31  6:44       ` reinkor
2017-01-26 16:18 ` Robert Eachus
2017-01-27  5:35   ` reinkor
2017-01-27  5:47   ` reinkor
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox