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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,c7c302806c75a91b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Received: by 10.66.73.1 with SMTP id h1mr2548656pav.0.1352353167343; Wed, 07 Nov 2012 21:39:27 -0800 (PST) From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Design by contract and control inversion Date: Thu, 01 Nov 2012 18:13:37 +0100 Organization: Ada @ Home Message-ID: References: NNTP-Posting-Host: 3v6cAj3XpvZHyQb0RelZrQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.02 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Path: s9ni86877pbb.0!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.mccarragher.com!news.grnet.gr!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2012-11-01T18:13:37+01:00 List-Id: Le Wed, 31 Oct 2012 20:28:30 +0100, Yannick Duch=C3=AAne (Hibou57) = a =C3=A9crit: > The only thing I could imagine, is to create a second type, `U`, = > re=E2=80=91interfacing `T`, and passed to the handlers instead of `T`:= > > > type T is private; > > type U (<>) is limited private; > > [=E2=80=A6] > > [=E2=80=A6] in the real thing I did, `U` only gets a subset of the sub= programs = > applicable to `T`. May make one feels it would be better to expression the subset relation = = with a type relation, i.e. type `T` would be a derived type of `U` (henc= e, = `U`'s properties, is a subset of that of `T`). Unfortunately, doing this: type U (<>) is tagged limited private; type T is new U with private; =E2=80=A6 leads into an issue: you want to disallow any instance of `U` = to be = created (the reason of the unknown discriminant), but this also disallow= = instantiation of `T` as=E2=80=91is, as `T` inherits the unknown discrimi= nant. Can = have a `Create` or `Instance` function, but would be cleaner to be able = to = get ride of this unknown discriminant. If `T` adds capabilities to `U`, = it = should be able to get ride of it, isn't it? That make me feel again that use of the unknown discriminant is too much= = like a hack, when you just want to disallow instantiation from the clien= t = side. Would be nice to have something to directly express it, not = involving any discriminants, which is a separate concept (indeed, the fu= ll = view of the type, does not have, and does not need any). There use to be thread on that topic, but can't remember which one it wa= s. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity