Special variables: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (syntax highlighting fixup automation)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by 2 users not shown)
Line 717:
...etc.</syntaxhighlight>
ERR is a special name, but only inside the context of the INQUIRE (and OPEN, and WRITE, ''etc.'') statement, it is not the name of an existing variable outside that statement whether defined by the language or by the programmer, and if the programmer were to define a variable called ERR it would have no relevance within that INQUIRE statement - though <code>ERR = ERR</code> ''would'' be workable if an ASSIGN statement had assigned statement label 666 to variable ERR. Similarly, the variable named FILENAME is declared by the programmer and because there are no reserved words, could be just FILE. Likewise, EXIST is declared (as LOGICAL) and IOSTAT (as INTEGER) as a mnemonic aid and also to save on the trouble of remembering whether the assignment works left-to-right or right-to-left in each case. It is right-to-left for FILE = ''filename'', input to the INQUIRE statement and left-to-right for EXIST = ''variable'', an output of the INQUIRE statement.
 
=={{header|FreeBASIC}}==
FreeBASIC has no 'special variables'.
 
=={{header|Go}}==
Line 1,015 ⟶ 1,018:
 
=={{header|Java}}==
Java is heavily object-oriented, and is mostly statically-typed. There aren't many special variables, or aggregates, similar to dynamically-typed languages.<br />
 
There is ''null'', which is used to represent an object which has no reference assigned.
<syntaxhighlight lang="java">
Object object = null
</syntaxhighlight>
 
There is ''true'' and ''false'' which are used to denote a ''Boolean'' value.
<syntaxhighlight lang="java">
boolean value = true
</syntaxhighlight>
 
There is the ''this'' and ''super'' variables, used to reference the current class and parent class, respectively.
<syntaxhighlight lang="java">
this.object
</syntaxhighlight>
<syntaxhighlight lang="java">
super(value)
</syntaxhighlight>
 
To avoid confusion to anyone unfamiliar with Java, there is the ability to import static, final, variables from other classes.<br />
While these are not 'special variables' they may appear that way to a new user.
<syntaxhighlight lang="java">
import static java.lang.Math.*;
</syntaxhighlight>
<syntaxhighlight lang="java">
double area = PI * (2 * 2);
</syntaxhighlight>
 
There is the first parameter of the ''main'' method, which is of type ''String[]''.<br />
It is non-null and includes any arguments depicted during execution.
<syntaxhighlight lang="java">
public static void main(String[] args)
</syntaxhighlight>
<br />
Additionally ...<br />
Java has only a few special variables. There is a <code>String</code>-Array for passing command-line-arguments to the program, and there is a <code>Class</code>-Object that can be accessed in a variable-like manner. It is used for reflection, (like examining and modifing class members, their type and modifiers during runtime).
There is the <code>System</code>-"Object" that contains various (mostly static) data about the enviroment the Java VM runs on, and it's cousin <code>Runtime</code> that provides data that is more prone to change during runtime, like available CPU cores and RAM.
Line 2,194 ⟶ 2,232:
 
=={{header|Wren}}==
Wren has two special variables ''this'' and ''super''. These can only beWhen used in a constructor or instance method of a class. ''this'' refers to the current instance and ''super'' refers to a super-class whose constructor or (typically overridden) method you wish to invoke. Here's an example.
<syntaxhighlight lang="ecmascriptwren">class Parent {
construct new(name) {
_name = name
Line 2,223 ⟶ 2,261:
My name is John and my parent's name is Fred.
</pre>
 
=={{header|Z80 Assembly}}==
It's somewhat debatable whether processor registers count as "variables," since they don't have a location in the address space but their contents can change. Excluding those for now, there are a few memory locations that have special meaning:
9,485

edits