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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ff5c149712ec0eb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!h2g2000hsg.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Interfaces and the Liskov Substitution Principle Date: 25 May 2007 00:52:21 -0700 Organization: http://groups.google.com Message-ID: <1180079541.558215.256570@h2g2000hsg.googlegroups.com> References: <1179953657.839272.160320@a26g2000pre.googlegroups.com> <1179991769.376381.252010@m36g2000hse.googlegroups.com> <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> <1180011507.159515.46920@o5g2000hsb.googlegroups.com> NNTP-Posting-Host: 137.138.37.241 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1180079544 31114 127.0.0.1 (25 May 2007 07:52:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 25 May 2007 07:52:24 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10) Gecko/20070228 Red Hat/1.5.0.10-0.1.slc3 Firefox/1.5.0.10,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: h2g2000hsg.googlegroups.com; posting-host=137.138.37.241; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:15927 Date: 2007-05-25T00:52:21-07:00 List-Id: On 25 Maj, 00:58, "Randy Brukardt" wrote: > > I was talking about real assignment - and this assumes that two > > objects already exist and we make one to be equal to the other. There > > is no way to do it right. > > (Using the *correct* terminology as Bob noted) Yes, thank you both for explaining it - I was using the C++ terminology. > Given the current Ada rules, what classwide assignment is good for is > *re*construction: > > procedure Do_Something(Y : out Object'Class) is > begin > Y := Constructor_Func (); > end Do_Something; > > that is, the replacement of an object with different one of the same type. > The Constructor_Func is dispatching on the real type of the LHS object Interesting. In most of the cases, the factory function creates the object of whatever type *it* decides (based on its parameters or some other input values) and initializes the class-wide type accordingly. The one above means "remake me, please", but it's applicability must be greatly limited - you neatly write , but it should be really . That complicates this scheme a bit. There is a very simple rule of thumb for checking whether any given OO pattern makes sense - try to stick it to the classical geometry example. If it falls off, beware. :-) -- Maciej Sobczak http://www.msobczak.com/