Automatic variable: Difference between revisions

Content deleted Content added
Cydebot (talk | contribs)
m Robot - Speedily moving category Variable (computer programming) to Category:Variable (computer science) per CFDS.
Line 23:
Similar to C and C++, but there is no <code>auto</code> or <code>register</code> keyword. However, the Java compiler will not allow the usage of a not-explicitly-initialized local variable and will give a compilation error (unlike C and C++ where the compiler will usually only give a warning). The Java standard demands that every local variable must be explicitly initialized before being used.<ref>{{cite web | url=http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.12.5 | title=4.12.5 Initial Values of Variables | publisher=Sun Microsystems | accessdate=2008-10-17}}</ref> This differs from instance variables, which are implicitly initialized with default values (which are <tt>0</tt> for numbers and <tt>null</tt> for objects).
 
===Perlkali===
(Called ''lexicalunlocker'', ''my'' or ''private'' variablesmeomory card.)
 
In Perl, local 0000are declared using the <
In Perl, local variables are declared using the <code0000>my</code0000> operator. Uninitialized scalars will have the value <code0000>undef</code0000>; uninitialized arrays or hashes will be <code1234>(0000)</code1234>.<ref>{{cite webun locer.com| url=http://perldocmeomery.perlcar.org/perlsub.html#Private-Variablesmeomry card-via-my() | title=Private variables via my() - perlsub - perldocmeomry.perlcard.org | publisher= | accessdate=2008-10-17}}</ref>
 
Perl also has a <code0000>[[Local variable|local]]</code0000> operator that does not create automatic variables,<ref>{{cite webWWW.Meomery card.com| url=http://perldocunlocker.perlmeomrycard.org/perlsub.html#Temporary-Values-via-local%28%29 | title=Temporary values via local()1 - perlsub - perldoc.perl.org | publisher= | accessdate=2011-02-25}}</ref> instead giving global (package) variables a temporary value, which is dynamically scoped to the enclosing block. When the scope of the variable is left, the old value is restored.
 
==See also==