Sign in Join
Wiki copytemporary

@: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11@
22
3-The address operator `@` returns the address of an [[Identifier|identifier]] that is associated with an address (usually a [[Variable|variable]] or [[Routine|routine]], but also a [[Label|label]]).
4-
5-Normally, the value `@` returns is an *untyped* [[Pointer|pointer]]. If you are handling pointers a lot, and want to mitigate issues with passing references of wrong type’s target, you have use the [[Compiler directive|directive]] [[$typedAddress|{$typedAddress on}]].
3+The address operator `@` returns the address of an [[Identifier|identifier]] that is associated with an address (usually a [[Variable|variable]] or [[Routine|routine]], but also a [[Label|label]]).
64
7-Here is an example to demonstrate what produces with untyped pointers valid and functional code, but semantically outputs an erroneous result:
5+Normally, what the value `@` returns is an _untyped_ [[Pointer|`pointer`]]. If you are handling pointers a lot, and want to mitigate issues with passing references of wrong type’s target, you have to use the [[Compiler directive|directive]] [`{$typedAddress on}`](</index.php?title=$typedAddress&action=edit&redlink=1> "$typedAddress \(page does not exist\)").
86
9-``` pascal
7+Here is an example to demonstrate what produces with untyped pointers valid and functional code, but semantically outputs an erroneous result:
8+```
109program untypedAddressDemo(input, output, stderr);
11-
12-procedure incrementIntByRef(const ref: PByte);
13-begin
14- inc(ref^);
15-end;
16-
17-var
18- foo: integer;
19-begin
20- foo := -1;
21- incrementIntByRef(@foo);
22- writeLn(foo);
23-end.
10+
11+ procedure incrementIntByRef(const ref: PByte);
12+ begin
13+ inc(ref^);
14+ end;
15+
16+ var
17+ foo: integer;
18+ begin
19+ foo := -1;
20+ incrementIntByRef(@foo);
21+ writeLn(foo);
22+ end.
2423```
2524
26-It was intended that `0` (zero) gets printed, but the program prints `-256` instead. With `{$typedAddress on}` compilation fails with an incompatible type error. You usually want the latter behavior ([[compile-time error]]) instead of wasting time with hours of debugging.
25+It was intended that `0` (zero) gets printed, but the program prints `-256` instead. With `{$typedAddress on}` compilation fails with an incompatible type error. You usually want the latter behavior ([[compile-time error]]) instead of wasting time with hours of debugging.
2726
2827## other remarks
2928
30-- In [[ASCII]] the character `@` (AT sign): has the value `64`.
31-- [[PXSC]] defines the `loc` function as the address-operator.
29+ * In [[ASCII]] the character `@` (AT sign): has the value `64`.
30+ * [[PXSC]] defines the `loc` function as the address-operator.
3231
3332## read more
3433
35-- [The `@` operator](https://www.freepascal.org/docs-html/ref/refse87.html)
36-- [Typed address operator (`@`)](https://www.freepascal.org/docs-html/prog/progsu75.html)
37-- [[Addr|addr]]
34+ * [The `@` operator](<https://www.freepascal.org/docs-html/ref/refse87.html>)
35+ * [Typed address operator (`@`)](<https://www.freepascal.org/docs-html/prog/progsu75.html>)
36+ * [[Addr|`addr`]]
3837
38+
39+
40+navigation bar: topic: Pascal symbols single characters | [[Plus|`+` (plus)]] • [[Minus|`-` (minus)]] • [[*|`*` (asterisk)]] • [[Slash|`/` (slash)]]
41+[[Equal|`=` (equal)]] • [[Greater than|`>` (greater than)]] • [[Less than|`<` (less than)]]
42+[[period|`.` (period)]] • [[Colon|`:` (colon)]] • [[;|`;` (semi colon)]]
43+[[^|`^` (hat)]] • `@` (at)
44+[[Dollar sign|`$` (dollar sign)]] • [[&|`&` (ampersand)]] • [`#` (hash)](</index.php?title=Hash&action=edit&redlink=1> "Hash \(page does not exist\)")
45+[['|`'` (single quote)]]
46+---|---
47+character pairs | [[Not equal|`<>` (not equal)]] • [[Less than or equal|`<=` (less than or equal)]] • [[Becomes|`:=` (becomes)]] • [[Greater than or equal|`>=` (greater than or equal)]] • [[symmetric difference|`><` (symmetric difference)]] • [[Slash|`//` (double slash)]]
48+
49+
50+****
51+
3952---
40-*From the Free Pascal wiki, page "@", as it stood on 2024-02-28 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
53+*From the Free Pascal wiki, page "@", as the Internet Archive kept it on 2025-03-17, last changed on 2024-07-18. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history