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: a07f3367d7,46b760ffb623378c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!news.k-dsl.de!news.uni-stuttgart.de!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Hiding the value of Constants 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: <30696d63-16e8-44e2-a4a5-db5095d7cfec@m3g2000pri.googlegroups.com> <4a531837$0$30227$9b4e6d93@newsspool1.arcor-online.net> <5b49f256-f779-4030-a50d-5f31fd08ddff@26g2000yqk.googlegroups.com> <0549aae1-d200-4c81-aa92-8d18df6cf0d4@b25g2000prb.googlegroups.com> <1dv621wlnwthy$.34p5zibbgti0.dlg@40tude.net> <1qye1tloa3y6i$.1x63ituluw0g4$.dlg@40tude.net> <1q139ij9zy8ap.1vnc5u4ncqdxb.dlg@40tude.net> <4a547413$0$31878$9b4e6d93@newsspool3.arcor-online.net> Date: Wed, 8 Jul 2009 14:20:50 +0200 Message-ID: <12tz12zpoputh.mr1k98qm2wtp.dlg@40tude.net> NNTP-Posting-Date: 08 Jul 2009 14:20:50 CEST NNTP-Posting-Host: c8894713.newsspool3.arcor-online.net X-Trace: DXC=7BPVT8gM56YU6b:FjPaGjQMcF=Q^Z^V3X4Fo<]lROoRQ^YC2XCjHcbYo5o:D:]i17\DNcfSJ;bb[UFCTGGVUmh?TLK[5LiR>kgRBFjOfZPL2oY X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6901 Date: 2009-07-08T14:20:50+02:00 List-Id: On Wed, 08 Jul 2009 12:25:23 +0200, Georg Bauhaus wrote: > Dmitry A. Kazakov schrieb: >> On Tue, 7 Jul 2009 13:28:01 -0700 (PDT), Adam Beneschan wrote: >> >>> On Jul 7, 12:53 pm, "Dmitry A. Kazakov" >>> wrote: >> I believe, nobody is satisfied how the rules handle subprograms >> and primitive operations. It is too easy to design a package specification >> which would make it unusable because of ambiguities introduced by >> "use"-ing. Yes prefix notation makes life easier, but it does not >> exterminate need in "use". Something quite radical has to be done about it >> anyway. One spends virtually hours trying to find a reason why the compiler >> rejects an interpretation the programmer sees as "obvious". > > The programmer seeing something as "obvious" is a hint to > what the problem with overloading actually is, and what the > (radical) solution looks like. (Really radical, in a gardening > sense, sort of. :-) Here, again, is the Max example: > > Max : constant Integer := 15; > Max : constant Float := 15.0; > > What seems obvious to me is that the programmer intends to > express the Max of two somethings that share some common > property: they both have a Max. But he/she wishes to do so > *without* explicitly programming the underlying common > structure! I don't see how an underlying structure would help. Consider both Integer and Float descendants of some Numeric type. Does that change anything? (see also below) > Perhaps it seemed obvious when writing the code, > or being lazy and not explicitly programming the common > property seemed justifiable at the time of writing. > IMHO this is an example of the presumption of "being obvious" > making things unecessarily complicated: the compiler would > have to resolve the overload that was introduced by the > programmer who *knew* how to resolve both the commonality > and the difference. (There are means in Ada to express > the same algorithm for two data structures, but anyway ...) I think that the idea is to express a commonality rather than resolve it. As an example take Integer'Last and Float'Last. Why they are allowed to be visible in the same context? How (semantically) they differ from Max? > The radical solution is to finally get rid of overloading! Yes, it is a very attractive idea. But the problem is, how to live with "+" defined both on Integer and Float? As I said earlier, the problem is not with variables. I think the language will continue reducing the number of declared variables down to virtually none. The problem is thousands of operations and types. Where would you get different names for all of them? How are you going to remember that mess? Consider a typical design of a library based on generics. It forces you to have identical names for everything declared in a generic package. The difference happens in the instances of. The names of the instances is a traditional torture to invent. As a result they are absolutely meaningless and impossible to remember. The compiler too has no idea how to help you in finding an instance of "indexing" a "generic map" with the element "T". > Just use one name for one thing in one region. See SPARK > for an example. > > In Ada, not using generics, but using overridden Max, > > Bounded_Structure: Finite_Order'class := ...; > begin > if Item < Bounded_Structure.Max then > ... You forgot that a polymorphic operation (Max) is a set of overloaded specific bodies. You have to allow specific bodies being named. In Ada these names overload. So the only way not to do it, is to go the path of C++ by providing unique names mangled by the type signatures, e.g. Max. Interestingly, this is how Ada 83 started. It still has disgusting attributes taking the form Type'Name. I hope you would agree that this is a road to hell? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de