Address of a variable: Difference between revisions

Content added Content deleted
(oberon-2)
Line 16: Line 16:
J : Integer;
J : Integer;
for I'Address use J'Address;</ada>
for I'Address use J'Address;</ada>
=={{header|ALGOL 68}}==
Basically ALGOL 68 refuses to let the programmer access the memory directly. The language does
allow "references" any variables. These references are effectively the address a particular
variable. But the value of the actual address is not available for printing or any arithmetic.
<pre>
[4]INT test := (222,444,666,888);
REF INT reference := test[3];
REF INT(reference) := reference + 111;
print(("test value is now: ",test))
</pre>
Output:
<pre>
test value is now: +222 +444 +777 +888
</pre>

The other reason specific addresses are using in languages like [[C]] to manipulate
devices. For this purpose site are expected to implement channels for their programmers to use.
To quote the ALGOL 68 Revised Report: <i>A "channel" corresponds to one or more physical devices (e.g.,
a card reader, a card punch or a line printer, or even to a set up in
nuclear physics the results of which are collected by the computer),
or to a filestore maintained by the operating system.</i>

To establish a channel with such a device there is a special standard procedure:<pre>
PROC establish = (REF FILE file, STRING idf, CHANNEL chan, INT p, l, c) INT: ~ </pre>
Where the <code>idf</code> string is text describing which device to open, and possibly options.
And <code>chan</code> is the actual device type. Standard CHANNEL in ALGOL 68 are <code>stand in chan</code>,
<code>stand out chan</code>, and <code>stand back chan</code>. Site would be expected to implement their own
CHANNELS for database queries and particle accelerators etc.


=={{header|C sharp|C #}}==
=={{header|C sharp|C #}}==