comp.lang.ada
 help / color / mirror / Atom feed
From: sbelmont700@gmail.com
Subject: Re: Type extension and discriminants
Date: Sat, 11 Oct 2014 14:09:48 -0700 (PDT)
Date: 2014-10-11T14:09:48-07:00	[thread overview]
Message-ID: <1d5e857d-1c16-40be-9f4d-fba44ce22e42@googlegroups.com> (raw)
In-Reply-To: <1m1grtt4tjy6m$.2tgdf5cel9tn$.dlg@40tude.net>

On Saturday, October 11, 2014 2:53:05 PM UTC-4, Dmitry A. Kazakov wrote:
> 
> Don't use this pattern, it simply does not work. Even without GNAT bugs.
> 
> However all GNAT compilers I know have serious problems with more than one
> 
> nested limited return. But if GNAT worked, this pattern will eventually hit
> 
> you back.
> 

The issue of favoring composition over inheritance is that if T1 has lots of operations, especially those which are unchanged (not overridden) for T2 (and T3, and T4, etc), then you end up with the hassle of writing all these one-line delegation methods.  It's easy enough to refactor this so that T1 and T2 both implement interface I, have T2 contain a reference to a T1 and just pass the calls through, but apart from being a PITA and unnecessary, often the compile-time safety is an advantage, not a drawback; any T2 is forced to use T1's (classwide) methods, and can NOT be reconfigured dynamically.  Obviously this a case-by-case sort of thing, but this is certainly a pattern any purportedly OOP language needs to support.

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


-sb


  reply	other threads:[~2014-10-11 21:09 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 [this message]
2014-10-12  6:51         ` Dmitry A. Kazakov
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