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,6aa1ec264ce25142 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.82.226 with SMTP id l2mr3014495wiy.1.1346240262669; Wed, 29 Aug 2012 04:37:42 -0700 (PDT) Path: e9ni72327350wia.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Real syntax problems in Ada Date: Wed, 29 Aug 2012 12:43:16 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <1p5r39cusgc1n$.18nj9sytckk6$.dlg@40tude.net> <289703e7-1fba-41ce-b781-9e58ff2ec7df@googlegroups.com> <1w3xr2kbz8a19$.wpfoz4p1j1sb.dlg@40tude.net> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 X-Trace: tigger.scc.uni-weimar.de 1346240263 10911 141.54.178.228 (29 Aug 2012 11:37:43 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Wed, 29 Aug 2012 11:37:43 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Content-Type: TEXT/PLAIN; charset=US-ASCII Date: 2012-08-29T12:43:16+02:00 List-Id: On Wed, 29 Aug 2012, Dmitry A. Kazakov wrote: > No, I meant rather this: > > generic package P (Foo : function return Integer; Q : package...) is ... Indeed, the syntax for declaring a generic something (after the keyword "generic" the parameters come first, and the something and its name comes last) is counter-intuitive, different from any other declarations, and hurts readability. Consider the following simple example: generic type Item is private; type Many_Items is array(Positive range <>) of Item; with function "<"(Left, Right: Item) return Boolean is <>; function Minimum(List: Many_Items) return Item; Ask programmers without Ada experience what this is. Most would read this as a generic declaration of something -- but how many would read this as the generic declaration of a function called "Minimum"? If the indention is lost, even Ada-programmers would have problems to find out *what* is generically declared (a function) and what its name is ("Minimum"). Your idea seems to be to alternatively write the above declaration as generic function Minimum (type Item is private; type Many_Items is Array (Natural Range <>) of Item; function "<"(Left, Right: Item) return Boolean is <>) (List: Many_Items) return Item; This would be a lot more readable. > The problem with that could be distinguishing generic and non-generic > signatures of generic subroutines: > > generic procedure Baz (X : Integer); > > Is X here a generic formal object or a plain argument of Baz? Here we are hurt by another minor but annoying inconsistency of the Ada syntax. Almost everywhere, we have to write "null" to make it explicit if we ask for nothing, or for nothing additional. E.g., we must write type X is new Tagged_Type with null record; instead of type X is new Tagged_Type; Similarly, we write "if B then null; else Do_Something end if;" instead of "if B then else Do_Something end if;". This is an advantage of Ada that improves readability and helps to catch flaws. Back to the issue you raised! If we introduce the notation "(null)" for empty parameter lists, we can easily solve your issue: generic procedure Baz_1 (with X: Integer) (null); -- X is a generic formal object, -- (I am not sure if we should allow or even require "with" here.) generic procedure Baz_2 (null) (X: Integer); -- X is a plain argument -- ---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany ---- ------ I love the taste of Cryptanalysis in the morning! ------