Change some keywords and enum manifests?

Nick Sabalausky a at a.a
Tue Apr 27 11:02:18 PDT 2010


"Adam D. Ruppe" <destructionator at gmail.com> wrote in message 
news:mailman.82.1272389432.3522.digitalmars-d at puremagic.com...
> On Tue, Apr 27, 2010 at 01:12:13PM -0400, bearophile wrote:
>> The situation of the 'static' keyword is silly.
>
> Static isn't bad - it always means the same thing: "this won't change
> across instances."
>
> class A {
> static void f(); // f does the same across all instances of A
> static int a; // same variable across all instances of A
> }
>
> void f() {
> static int a; // same across all calls of function f()
> }
>
> The compile time ones also apply in the same way, if you think of the
> program as being like a class, and instances of the program at runtime as
> being objects.
>
> static if(a) { } // doesn't change across instances of the program
> static assert(a) // same as static if
>
>
> The only place I can think of where it doesn't fit perfectly is static
> import, and even then it fits loosely: calls to that module will always
> be the same (fully qualified).
>
>
> I'm ok with keyword reuse when it all fits under one main definition, 
> which
> static does. If you are giving multiple definitions to one word though, 
> that's
> less ideal.
>
> enum works fine by me too by the way: it is any compile time value, which
> also applies to manifest constants.
>

pure: The same input always results in the same output, and with no side 
effects.

A variable can be thought of as a zero-argument function (particularly true 
if you think of properties as being variables), and likewise, a manifest 
constant can be thought of as a zero-argument pure function (although, so 
can immutable vars, for that matter).

-------------------------------
Not sent from an iPhone.





More information about the Digitalmars-d mailing list