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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: How come Ada isn't more popular? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1169531612.200010.153120@38g2000cwa.googlegroups.com> <1mahvxskejxe1$.tx7bjdqyo2oj$.dlg@40tude.net> <2tfy9vgph3.fsf@hod.lan.m-e-leypold.de> <1g7m33bys8v4p.6p9cpsh3k031$.dlg@40tude.net> <14hm72xd3b0bq$.axktv523vay8$.dlg@40tude.net> <4zwt33xm4b.fsf@hod.lan.m-e-leypold.de> <1j7neot6h1udi$.14vp2aos6z9l8.dlg@40tude.net> <1170347180.14376.104.camel@localhost.localdomain> <1nxunq6pci4r1$.1nnigcjicppwy.dlg@40tude.net> <1170426442.9393.29.camel@localhost.localdomain> Date: Fri, 2 Feb 2007 17:07:14 +0100 Message-ID: <1ek9qlep7kijw$.e7i6x934g2ip$.dlg@40tude.net> NNTP-Posting-Date: 02 Feb 2007 17:07:14 CET NNTP-Posting-Host: ad3cb2d7.newsspool3.arcor-online.net X-Trace: DXC=WK1_>VAD_=QAX0F2i>_[]gjkLWZ1FP X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8843 Date: 2007-02-02T17:07:14+01:00 List-Id: On Fri, 02 Feb 2007 15:27:22 +0100, Georg Bauhaus wrote: > So that we have > > function next is > new Inc(T => Integer, Increment => 1); > function next_but_one is > new Inc(T => Integer, Increment => 2); > > pragma assert(next_but_one(1) = 1 + next(x)); > > This isn't exactly like > > (define inc > (lambda (Increment) > (lambda (x) > (+ Increment x)))) > > (defined next (inc 1)) > (defined next-but-one (inc 2)) > > because next and next_but_one cannot be passed outwards in > Ada. (Which I understand you don't want anyway ;-) That depends on what you mean > > Or similarly, but not creating function instances, > > type Section(Increment: Additive) is new Additive with private; > function inc(x: Section) return Integer; > > next: Section(Increment => 1); > next_but_one: Section(Increment => 2); > > pragma assert(inc(next_but_one) = 1 + inc(next)); > > And you cannot pass these objects outwards, either. Why should I pass them outwards? It seems like three mixed issues: 1. Types of subprograms (Ada should have them, but it does not) 2. Specialization, a sugar for wrappers (It could be useful too) 3. Upward closures (Bad idea, why next should be visible in places where 1 does not exist?) >> function Increment return Additive is abstract; >> -- Better be getter/setter pair. Unfortunately Ada does not have >> -- "abstract variable interface" it should have > > You could start by declaring > > type Integer is new Controlled > and Accessors > and Additive with private; You don't need to specify all interfaces in advance: type Integer_For_Foo is new Integer and Interface_For_Foo; (Multiple inheritance from concrete types shall be.) >> BTW, can you do the same for the case where Increment were Integer and Arg >> were Float? [ You would need multiple dispatch in "+", > > Why would I need multiple dispatch? I could just as well state > the requirement in the generic "+" function(s), taking arguments > of type Integer and Float. Geometric explosion of variants. Then you defeat the very idea of generic programming, which was to talk in terms of Additive, rather than in all concrete instances of in this concrete program. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de