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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Functions vs constants Date: Tue, 22 Jul 2014 00:41:05 +0300 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: rFX7cZOSaeuGGZI2vwQTaQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.12.4 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:21102 Date: 2014-07-22T00:41:05+03:00 List-Id: Niklas Holsti wrote: > On 14-07-22 00:18 , Victor Porton wrote: >> Isn't the following a mis-design of Ada? >> >> Constants in a good programming language should be equivalent to >> argument- less functions which return these constants. > > Possibly, for some personal concept of "good". > >> However, in Ada functions can be overloaded by their return type, while >> constants cannot. >> >> Mad idea > > Why mad? Because my idea looks like as something unreliable. (However it should not be quickly dismissed by this argument, because the same argument could apply to overloading functions.) >>, but I propose it: Make in a future specification of Ada constants >> overloadable (moreover, make constants argument-less functions). > > Others have also suggested this, and even wider overloading (including > variables). Arguments against the idea relied on subjective opinion, if > I remember correctly. > > I do not see a pressing need to make constants (or variables) > overloadable. If I want to overload constants, I define overloaded > functions which return those constants. As for variables, they are > nearly always so local that overloading seems overkill. The idea of overloading constants comes from the use case, when I have one constant and after revising my source code want to make two overloaded entities with that name instead of one. This would require me first to replace the existing constant with a function, and this step looks quite ridiculous for me (when I add something to the program, the old code should not need modifications). I agree that overloading variables is an overkill. (And I do not know any language where vars can be overloaded.) But the idea to make constants a kind of functions is viable. -- Victor Porton - http://portonvictor.org