static static

Steven Schveighoffer schveiguy at yahoo.com
Thu Nov 12 04:04:00 PST 2009


On Tue, 10 Nov 2009 16:56:11 -0500, bearophile <bearophileHUGS at lycos.com>  
wrote:

> Steven Schveighoffer:
>
>> What's the advantage over:
>>
>> static int y;
>>
>> T foo(T)(T x) {
>>     // ...
>> }
>
> That the global name space is kept clean, the "y" name can be seen only  
> inside foo. Reducing the visibility of names is useful to keep things  
> tidy. (Inside normal functions in D static has just that purpose).

Doesn't static do that already?  I mean keep y within the module  
namespace.  Sure, it's visible to other functions in foo's module, but not  
the global namespace.  Or does that not work in D...

-Steve



More information about the Digitalmars-d mailing list