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!news1.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.arcor.de!newsspool4.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> Date: Fri, 2 Feb 2007 10:20:05 +0100 Message-ID: <1nxunq6pci4r1$.1nnigcjicppwy.dlg@40tude.net> NNTP-Posting-Date: 02 Feb 2007 10:20:05 CET NNTP-Posting-Host: 32b6264d.newsspool4.arcor-online.net X-Trace: DXC=C^]bIHG\R;B2:OR3:3gaE@4IUKkgBVR84oba9?ZJ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8838 Date: 2007-02-02T10:20:05+01:00 List-Id: 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. This follows from even simpler rule: generic <--> class-wide instance <--> specific ------------------------------ = polymorphic BTW, can you do the same for the case where Increment were Integer and Arg were Float? [ You would need multiple dispatch in "+", that is the case where any system without subtypes would quickly collapse. For a vivid example see String/Unbounded_String/Wide_String/... mess in Ada.] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de