comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: What is your opinion on Global Objects?
Date: Fri, 21 Nov 2014 10:01:35 +0100
Date: 2014-11-21T10:01:35+01:00	[thread overview]
Message-ID: <1tz9u84opgdwc$.a7dpkorp05gp.dlg@40tude.net> (raw)
In-Reply-To: m4lmq9$970$1@dont-email.me

On Thu, 20 Nov 2014 22:35:16 +0100, J-P. Rosen wrote:

> Le 20/11/2014 21:33, sbelmont700@gmail.com a écrit :
>> For what it's worth, I'm in the "pass everything as an argument" camp
>> (and really functional programming in general), and loathe the
>> 'hidden state' setup, for the following reasons:
> Let's see what the other camp has to respond...
> 
>> 1. You are hardcoded to a particular implementation (i.e. no dispatching)
> Yes, it is more static, therefore safer and more easily provable.

This is a bit contradictory. Proofs as such are always against some stated
things. That already presumes several instances. Some instances may
withstand the proof some don't. Thus the idea of proving an inherent
singleton looks somewhat dubious. Singleton is only in the usage not a
property.

Anyway proving things about a type (singleton-object) might be easier than
doing this for an ad-hoc package.

> Dispatching is a very powerful tool, but only when you really need it.

Dispatching does not make sense for singletons, but Ada won't do any
dispatch anyway since the object's type is not class-wide.

>> 2. You always end up needing a second object, no matter much you think you
>> don't think you will.
> Doesn't meet my experience. Knowing that by design there can be only one
> object simplifies understanding and provability. You don't have to worry
> about which object you are dealing with - there is only one.

But the design may change and maintaining changes on the client side is
easier when the object is properly typed rather than when it is implicit,
in an assorted sets of subprograms stuffed into a package.

And you forgot about reuse. A singleton implementation may use some other
types implementations or provide its implementation for reuse.

>> 3. The majority of the program becomes impure
> ??? Please explain you notion of "purity".

I understood it as:

Pure = the only side effect is on the mutable arguments and/or the result.

>> 5. Everything is compile-time constant (i.e. no creating or deleting things dynamically).
> I would regard this as a huge benefit - dynamicity has always been
> opposed to simplicity and provability.

Huh, that reminds me of a relatively fresh discussion about termination of
a library-level task in Ada. A typical singleton, isn't it? Yet impossible
to terminate on application exit! Making it an access type (=not a
singleton) or moving out of the library level solved the problem.

Ego, it is not simple to have things static, though most things aren't any
static anyway, not even keeping them at the library level is simple.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2014-11-21  9:01 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18  1:36 What is your opinion on Global Objects? Hubert
2014-11-18  2:52 ` Jeffrey Carter
2014-11-18  3:08   ` Hubert
2014-11-18  3:16     ` Shark8
2014-11-18  5:09     ` Jeffrey Carter
2014-11-18 11:23     ` Brian Drummond
2014-11-19  2:50       ` Hubert
2014-11-19  3:03         ` Jeffrey Carter
2014-11-19  9:13           ` Hubert
2014-11-19 10:22             ` J-P. Rosen
2014-11-19 17:37             ` Jeffrey Carter
2014-11-20 16:34         ` Stephen Leake
2014-11-20 21:11           ` Adam Beneschan
2014-11-21 15:25             ` Stephen Leake
2014-11-21 21:53             ` Randy Brukardt
2014-11-21  1:25           ` Hubert
2014-11-21  3:00           ` Brad Moore
2014-11-19 10:11   ` Jacob Sparre Andersen
2014-11-20  6:21     ` Hubert
2014-11-18  8:54 ` Dmitry A. Kazakov
2014-11-20 20:33 ` sbelmont700
2014-11-20 21:35   ` J-P. Rosen
2014-11-21  1:02     ` sbelmont700
2014-11-21  1:31       ` Hubert
2014-11-21  9:01     ` Dmitry A. Kazakov [this message]
2014-11-22  7:46       ` J-P. Rosen
2014-11-22  9:02         ` Dmitry A. Kazakov
replies disabled

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