comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Re: Functions vs constants
Date: Tue, 22 Jul 2014 00:41:05 +0300
Date: 2014-07-22T00:41:05+03:00	[thread overview]
Message-ID: <lqk1dd$3j7$1@speranza.aioe.org> (raw)
In-Reply-To: c35fbuF747qU1@mid.individual.net

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

  reply	other threads:[~2014-07-21 21:41 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 21:18 Functions vs constants Victor Porton
2014-07-21 21:28 ` Victor Porton
2014-07-21 21:49   ` Shark8
2014-07-21 21:52     ` Victor Porton
2014-07-21 21:59       ` Adam Beneschan
2014-07-21 21:35 ` Niklas Holsti
2014-07-21 21:41   ` Victor Porton [this message]
2014-07-21 23:23   ` Randy Brukardt
2014-07-22  7:42     ` Dmitry A. Kazakov
2014-07-22 22:07       ` Randy Brukardt
2014-07-23  7:55         ` Dmitry A. Kazakov
2014-07-23 21:44           ` Randy Brukardt
2014-07-23 12:37         ` G.B.
2014-07-23 22:12           ` Randy Brukardt
2014-07-24  7:20             ` Stefan.Lucks
2014-07-25  4:43               ` Randy Brukardt
2014-07-26  2:36                 ` Shark8
2014-07-24  8:27             ` Georg Bauhaus
2014-07-24 10:11               ` Dmitry A. Kazakov
2014-07-24 10:49                 ` G.B.
2014-07-24 12:50                   ` Dmitry A. Kazakov
2014-07-25  4:56               ` Randy Brukardt
2014-07-25  6:45                 ` Georg Bauhaus
2014-07-25 10:46                   ` G.B.
2014-07-25 19:31                   ` Randy Brukardt
2014-07-25 20:02                     ` Dmitry A. Kazakov
2014-07-26  2:45                       ` Shark8
2014-07-26  8:02                         ` Dmitry A. Kazakov
2014-07-26 14:03                           ` Shark8
2014-07-26 14:18                             ` Dmitry A. Kazakov
2014-07-21 21:55 ` Victor Porton
2014-07-22  7:06 ` Maciej Sobczak
2014-07-22  7:50   ` Dmitry A. Kazakov
2014-07-22 22:14     ` Randy Brukardt
2014-07-23 13:21       ` Stephen Leake
2014-07-23 13:27         ` Victor Porton
2014-07-23 15:10         ` Adam Beneschan
2014-07-23 21:57 ` Robert A Duff
2014-07-24 12:25   ` Victor Porton
2014-07-24 15:53     ` Robert A Duff
2014-07-24 15:57       ` Victor Porton
2014-07-24 16:47   ` Pascal Obry
2014-07-24 12:26 ` anon
2014-07-24 12:52 ` Victor Porton
2014-07-24 16:01   ` Robert A Duff
2014-07-24 16:15     ` Adam Beneschan
2014-07-25  5:05     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox