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 Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? 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> From: Markus E Leypold Organization: N/A Date: Fri, 02 Feb 2007 13:34:21 +0100 Message-ID: User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:WW/F/LuF2oqsI3NqV4seo+OKwXk= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.74.62.184 X-Trace: news.arcor-ip.de 1170419365 88.74.62.184 (2 Feb 2007 13:29:25 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news2.google.com comp.lang.ada:8854 Date: 2007-02-02T13:34:21+01:00 List-Id: "Dmitry A. Kazakov" writes: > On Thu, 01 Feb 2007 17:26:21 +0100, Georg Bauhaus wrote: > >> On Thu, 2007-02-01 at 15:22 +0100, Dmitry A. Kazakov wrote: > >>> On Wed, 31 Jan 2007 16:16:20 +0100, Markus E Leypold wrote: >> >>>> BTW -- another argument _for_ a builtin list syntax. >>> >>> Hey, Ada already has ()-brackets. Maybe our Unicode fans would propose >>> special glyphs for )), ))), )))), ))))), )))))) etc. Is it what you mean as >>> special syntax? (:-)) >> >> 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? (:-)) > >> What does a list syntax buy us if there is no argument pattern matching, >> or no data structure pattern matching in Ada? Brevity? > > There is no need in pattern matching. What is actually required in Ada is > abstract aggregates, i.e. an ability do have user-defined constructor > functions with the parameter specified in the form of a list. > >> generic >> type T is private; >> with function "+"(a, b: T) return T; >> increment: T; >> function Inc(arg: T) return T; >> >> function Inc(arg: T) return T is >> begin >> return increment + arg; >> end Inc; >> >> Looks like more code, and I hear an FP advocate saying, "in FP, >> you just ...". Any sentence that starts with "You just ..." >> is suspicious :-) >> >> Can I have this without generics, please, Dmitry? ;-) > > Sure you can: > > 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: > > function Increment return Additive is abstract; > -- Better be getter/setter pair. Unfortunately Ada does not have > -- "abstract variable interface" it should have > > function Inc (Arg : Additive'Class) return Additive'Class is > begin > return Increment + Arg; > end Inc; > > There is a very simple rule for all this: > > 1. Formal generic subroutines -> abstract primitive operations > 2. Subroutines in the body -> class-wide operations. So you derive from Additive to get a specific implementation? Like type Vector is Additive with ...; type CountVal is Additive with ...; Right? But then, you should note that with C: Countval; Inc(C). returns an 'Additive', not a 'CountVal'. That is one problem. The other is of course that Increment is not initialized. This is exactly what generics are here to solve. Regards -- Markus