Global const variables

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 21 10:00:48 PDT 2014


On Tuesday, 21 October 2014 at 16:56:06 UTC, Solomon E wrote:
> On Tuesday, 21 October 2014 at 15:51:27 UTC, MachineCode wrote:
> ...
> ...
>>
>> pure functions are also supposed to don't use global variables 
>> at all, according to functional programming paradigm
>
> Pure functions are immutables (constants but not "const" in the 
> D or C++ senses) and can use other immutables, even if they're 
> global immutables. (I guess it would be better though always to 
> have a named top scope instead of everyone in the world having 
> the same global scope :-)

You *do* have a named top scope, the module name (which is 
accessible with prefixing a symbol with ., i.e., .x refers to the 
symbol x at module scope). There is no such thing as global scope 
in D.


More information about the Digitalmars-d-learn mailing list