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: a07f3367d7,da85d9aaf769b16a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Generic package parameters not externally visible : what's the rational ? References: <10eygvuzeit9g.xwy2wanxoxgf$.dlg@40tude.net> <1kf8mo4r9lqxg.1tdhqe6femt9m.dlg@40tude.net> <1r8etjwa9k46n.3pyj04jn686o$.dlg@40tude.net> From: Stephen Leake Date: Sat, 31 Oct 2009 08:44:18 -0400 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (windows-nt) Cancel-Lock: sha1:MAuWESTYYJD4ght3wnymGD2zRRg= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: 918c54aec311ee197caa731596 Xref: g2news2.google.com comp.lang.ada:8924 Date: 2009-10-31T08:44:18-04:00 List-Id: "Dmitry A. Kazakov" writes: > On Fri, 30 Oct 2009 06:25:21 -0400, Stephen Leake wrote: > >> "Dmitry A. Kazakov" writes: >> >>> My take is that any generic code is potentially broken. Anyone who uses >>> generics beyond very trivial cases should know that, and mentally prepare >>> himself to fix his code over and over again. >> >> That is certainly not my experience. I use generics extensively; it's >> one of the best features of the language. > > Do you use generic in other generics? Yes. See http://www.stephe-leake.org/ada/sal.html, in particular the sal-gen-alg hierarchy. You'll have to download and unpack the code; my webserver doesn't have enough space for the unpacked HTML version (guess it's time to spend more money on the web server). > This requires a bit explanation. A set of generics sharing some common > parameter (like the number type in a generic matrix package) are kind of > class, i.e. they declare sets of types dependant on the parameter (like > vector, matrix etc). I call this almost "trivial". Right; SAL has that in sal-gen_math. > Non-trivial it becomes when you have several such axes. Yes. For example, Unbounded_Arrays have Index_Type and Item_Type. > Here is an example of a mesh of generic packages with 4 axes: > > http://www.dmitry-kazakov.de/ada/fuzzy.htm#8 > > Note that semantically the example is quite simple, almost evident. Its > implementation and use is horrific. I would never consider it "fixed". Sorry, I don't see the complexity; what are the four axes? There are problems that can't be solved in Ada; that doesn't make Ada useless! Problems that can be almost solved, and push the boundaries of the language, and be very frustrating. > As for being the "best language feature", I hope that you would easily find > lots of more useful and advanced Ada features. Defining a metric on Ada features is not easy. My vote for best feature changes month to month; the best one is the one I most recently used to solve a hard problem. This month, that's generics. In previous months, it's been tasking, dispatching, interfaces, and rep clauses on packed record types. > What about unconstrained types? Yes, if the metric is "things that other languages don't have", that's high on the list. > User-defined numeric types? Not so important; I end up using the compiler types anyway, except for Unsigned_n in packed records. Ada should have defined _all_ of Unsigned_n, for n = 1 .. 64, in the first place. Distinct numeric types (derived from compiler defined types) is important. > Packages (vs. types) as encapsulation modules? That's just obvious; I wouldn't use a language that doesn't have that :). Even C++ has that now. Not called packages, but close enough. > If any of these were removed it would not be Ada. On the contrary, > Ada without generics sounds quite plausible to me. True. Ada without overloading is "plausible" as well. But that's just another metric. -- -- Stephe