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,a9bab26b6fe54a36 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Pondering what rationale behind record type 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: <90148303-4dc4-4c05-882f-88dd69a95494@z13g2000prk.googlegroups.com> <92quueFnsfU1@mid.individual.net> <4dc864b9$0$6890$9b4e6d93@newsspool2.arcor-online.net> <4dc90f7a$0$7659$9b4e6d93@newsspool1.arcor-online.net> Date: Tue, 10 May 2011 14:08:33 +0200 Message-ID: <11dlfbvj00hru$.7zkw6im0a7gj$.dlg@40tude.net> NNTP-Posting-Date: 10 May 2011 14:08:33 CEST NNTP-Posting-Host: 313f2b31.newsspool3.arcor-online.net X-Trace: DXC=a;ZOEND_k:EAa;:RKVJ>LEMcF=Q^Z^V3H4Fo<]lROoRA8kF On Tue, 10 May 2011 12:12:10 +0200, Georg Bauhaus wrote: > On 10.05.11 09:45, Dmitry A. Kazakov wrote: >> On Tue, 10 May 2011 00:03:37 +0200, Georg Bauhaus wrote: >> >>> First, in the phrase "end X", the "X" part can usually be omitted. >> >> That is another fix to do: a default profile which would forbid omitting >> the name. I saw no Ada program in my life which omitted names in the ends. >> >>> So whenever we put "record" (or "case", or "if", etc) after an "end", >> >> These are anonymous constructs. > > Though a loop can have a name. > > Anything wrong with (i.e. makes you shudder) > > Label_A: loop > ... > end loop Label_A; > > ? loop A do ... end A; >> The only reason why record bracket should >> not contain its name is when there is no name, e.g. as Randy has pointed >> out, in an anonymous record type. They are illegal in Ada, but an imaginary >> example could be: >> >> function Get_Token (File : File_Type) return >> (Matched : Boolean; Length : Positive) record >> ... > > In order to be competitive in the current discussion, > pro "end [X]", the example would have to be > > type Get_Token is function (File : File_Type) return > ((Matched : Boolean; Length : Positive) record > case Matched is > when True => Token : String (1..Length); > when False => null; > end case; > end record) > end Get_Token; No, Get_Token would be a function-type. E.g. type Func is function (X : Float) return Float; Then function Integrate (...; What : Func) return Float; Which could be be anonymous as well: function Integrate (...; What : function (X : Float) return Float) return Float; Or the example with Get_Token: procedure Parse ( File : File_Type; Get_Token : function (File : File_Type) return ((Matched : Boolean; Length : Positive) record case Matched is when True => Token : String (1..Length); when False => null; end case; end record ); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de