www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Global variables

reply "Saaa" <empty needmail.com> writes:
How are global variables accessed?

If a function wants to read/write to one, will it get a reference to it or a 
copy?

(I should learn asm :) 
Feb 20 2008
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
"Saaa" wrote
 How are global variables accessed?

 If a function wants to read/write to one, will it get a reference to it or 
 a copy?

 (I should learn asm :)

All usage of global variables reference the same data. If you want a copy, declare a local variable and copy the value of the global to the local variable. -Steve
Feb 20 2008
parent "Saaa" <empty needmail.com> writes:
Ok, thanks.
Using global variables isn't a performance penalty then.

 All usage of global variables reference the same data.  If you want a 
 copy, declare a local variable and copy the value of the global to the 
 local variable.

 -Steve
 

Feb 20 2008