comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Type extension and discriminants
Date: Sun, 12 Oct 2014 08:51:32 +0200
Date: 2014-10-12T08:51:32+02:00	[thread overview]
Message-ID: <jh5l7dlsfdxb.179ypo1ewfmoh$.dlg@40tude.net> (raw)
In-Reply-To: 1d5e857d-1c16-40be-9f4d-fba44ce22e42@googlegroups.com

On Sat, 11 Oct 2014 14:09:48 -0700 (PDT), sbelmont700@gmail.com wrote:

[...]
> Obviously this a case-by-case sort of thing, but this is certainly a
> pattern any purportedly OOP language needs to support.

No. The language should support constructors, not this nonsense (I mean
returning limited objects rubbish).

>> In short, limited return (constructing function) and limited aggregate are
>> not suitable for construction of parent objects which private discriminants
>> and components.
> 
> +1(000).  This is especially aggravating, because Ada's access
> discriminants and pass-by-reference semantics are so totally superior for
> saving references to other objects without having to resort to the heap.

Well, access discriminants were invented as a hack, e.g. for having mix-ins
instead of honest multiple inheritance or for circumvention of function's
"in" parameter modes etc.

An access discriminant represent a serious safety problem, in combination
with dynamic accessibility checks, a deadly problem.

> But the intermixing of "true" discriminated records (i.e. variant records,
> where the structure actually depends on the discriminant), and "fake"
> discriminated records that just use them when they need a constant always
> seems to cause endless headaches.

Discriminants are misused in many ways. Having an immutable (constant)
record member is one of them.

> I just wish I had a better idea of how
> to do it, because C++ initializer lists are a syntax abomination. :'-(

The language should have proper abstraction mechanisms. Ada is only halfway
there. Otherwise a discriminant would be a pure type constraint which
implementation would not necessarily be a record member while the type
would not necessarily be a record. Ugly Ada 2012 aspects are somewhat
would-be discriminants.

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

  reply	other threads:[~2014-10-12  6:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 20:55 Type extension and discriminants sbelmont700
2014-10-10 22:34 ` Randy Brukardt
2014-10-11 17:45   ` sbelmont700
2014-10-11 18:44     ` Simon Wright
2014-10-11 18:52     ` Dmitry A. Kazakov
2014-10-11 21:09       ` sbelmont700
2014-10-12  6:51         ` Dmitry A. Kazakov [this message]
2014-10-12 16:27     ` AdaMagica
replies disabled

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