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,16f39b4f57339dcb X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!e19g2000prn.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Constant as anonymous functions : the outer space beast is back Date: Tue, 2 Feb 2010 13:26:25 -0800 (PST) Organization: http://groups.google.com Message-ID: <18159050-6ea0-4bc8-ab62-329fab270f0e@e19g2000prn.googlegroups.com> References: <3c43bf9d-75f1-4d09-9388-65b83cafb1d9@j14g2000yqm.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1265145986 13780 127.0.0.1 (2 Feb 2010 21:26:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Feb 2010 21:26:26 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e19g2000prn.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8862 Date: 2010-02-02T13:26:25-08:00 List-Id: On Jan 29, 6:42=A0pm, "Randy Brukardt" wrote: > "Robert A Duff" wrote in messagenews:wccy6= jkz46l.fsf@shell01.TheWorld.com... > > > "Hibou57 (Yannick Duch=EAne)" writes: > > >> I'm back with the topic =A0constant as anonymous functions =A0( I've > >> opened last year, about 10 months ago if my mind is right ) ... > > ... > >> Who want to talk about this subject ? > > > Umm... =A0Maybe you should tell us all what you mean by > > "constant as anonymous functions", or quote your 10-month-old > > ideas, just in case some of us have forgotten, or missed it > > the first time around. > > I think he's talking about making constants overloadable, so that they > resolve like functions. This sounds suspiciously similar to something tha= t > one of your esteamed colleagues (me) suggested in the last couple of week= s. > The idea didn't get much traction, however. > > Specifically, I was proposing that use clauses treat objects as > overloadable, rather than causing cancelation semantics. This would reduc= e > the maintenance hazard of use clauses (caused when the addition of unrela= ted > declarations causes existing code to fail to compile). The subject came u= p > within the context of "integrated packages", which have the effect of > forcing the problems of use clauses on clients whether they like it or no= t. > I was trying to mitigate that danger. > > Anyway, I wasn't trying to suggest that we go any further than that, as > (arguably) there is a significant readability decrease if you apply > overloading to all object references everywhere. The issue is that local > objects would no longer hide distant ones, meaning that determining the > actual item denoted by a name would be much harder. I'm not sure if this = is > really an important issue or not, but I would expect it to be used to der= ail > any attempt at an overall change. > > Specifically, consider something like the following if overloading was > allowed for objects: > > package P is > =A0 =A0 Count : constant Float :=3D 10; > end P; > > with P; use P; > with Ada.Float_Text_IO; > procedure Do_It is > =A0 =A0 Result : Float :=3D 0.0; > begin > =A0 =A0 =A0for Count in 1 .. 10 loop > =A0 =A0 =A0 =A0 =A0 Result :=3D Result + Count; > =A0 =A0 =A0end loop; > =A0 =A0 =A0Ada.Float_Text_IO.Put(Result); > end Do_It; > > This program would print 100.0 if objects (or just constants for that > matter) had full overloading; it is illegal in Ada today (because of the > type error). Probably the programmer expects a result of 55.0, and would = be > quite surprised that they didn't get it. It would take a long time to > realize that Count does not denote the object directly declared on the > previous line! (Even if you were aware of this possibility, you'd probabl= y > think many other things were wrong before checking to see if the problem = is > in the interpretation of Count.) Some problems like that could be mitigated by defining overloading only for constants declared with an that contains the word "constant". I.e. *not* for loop variables, IN parameters, exception occurrence variables in handlers, .............. Actually, I suspect that that's the kind of constant the OP was thinking of, not everything that the language defines as having a constant view. -- Adam