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 autolearn=ham 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!t-online.de!news.karotte.org!news2.arglkargh.de!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? From: Georg Bauhaus In-Reply-To: <1nxunq6pci4r1$.1nnigcjicppwy.dlg@40tude.net> 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> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: # Message-ID: <1170426442.9393.29.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Date: Fri, 02 Feb 2007 15:27:22 +0100 NNTP-Posting-Date: 02 Feb 2007 15:27:22 CET NNTP-Posting-Host: 8937e98b.newsspool3.arcor-online.net X-Trace: DXC=UY40C^N_BlVaAeROF2PWMQMcF=Q^Z^V3X4Fo<]lROoRQgUcjd<3m<;RceNShYeeVg\PCY\c7>ejVXdm64Ij>fV1YUNFJ4GL_^XU X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8842 Date: 2007-02-02T15:27:22+01:00 List-Id: On Fri, 2007-02-02 at 10:20 +0100, Dmitry A. Kazakov wrote: > On Thu, 01 Feb 2007 17:26:21 +0100, Georg Bauhaus wrote: > > Actually, a syntax that is used in a theory book is > > {left/right paren}{subscript i}. > > Great. The next step would be to introduce expression in subscripts: )2+1 = > )3 = ))). Right? Then we proceed to )f(...) where f is a free function that > determines the number of brackets. OK? Now the question is, is it still > syntax? (:-)) In Lisp, yes, every Lisp programmer creates his or her own syntax anyway. :-) In the text book this only serves to point out that a left bracket must match a right bracket on the stack. The index prevents mixing parens. > type Additive is abstract; -- Should be enough for an interface > function "+" (A, B : Additive) return Additive is abstract; > > Here I am not sure about "increment" variable, because it is not > initialized. Anyway: That's the point: you create instances of functions that return the sum of their one argument plus an Increment. The Increment is bound to a value at the point of instantiation. 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 ;-) 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. > 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; > 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.