Sign in Join
Wiki copytemporary

@: what changed

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

OldNewLine
11@
22
33The 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]]).
44
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\)").
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|`{$typedAddress on}`]].
66
77Here is an example to demonstrate what produces with untyped pointers valid and functional code, but semantically outputs an erroneous result:
88```
99program untypedAddressDemo(input, output, stderr);
1010
1111 procedure incrementIntByRef(const ref: PByte);
1212 begin
1313 inc(ref^);
1414 end;
1515
1616 var
1717 foo: integer;
1818 begin
1919 foo := -1;
2020 incrementIntByRef(@foo);
2121 writeLn(foo);
2222 end.
2323```
2424
2525It 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.
2626
2727## other remarks
2828
2929 * In [[ASCII]] the character `@` (AT sign): has the value `64`.
3030 * [[PXSC]] defines the `loc` function as the address-operator.
3131
3232## read more
3333
3434 * [The `@` operator](<https://www.freepascal.org/docs-html/ref/refse87.html>)
3535 * [Typed address operator (`@`)](<https://www.freepascal.org/docs-html/prog/progsu75.html>)
3636 * [[Addr|`addr`]]
3737
3838
3939
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-****
40+**navigation bar: topic: Pascal symbols**
41+
42+_single characters:_ [[Plus|`+` (plus)]] • [[Minus|`-` (minus)]] • [[*|`*` (asterisk)]] • [[Slash|`/` (slash)]] • [[Equal|`=` (equal)]] • [[Greater than|`>` (greater than)]] • [[Less than|`<` (less than)]] • [[period|`.` (period)]] • [[Colon|`:` (colon)]] • [[;|`;` (semi colon)]] • [[^|`^` (hat)]] • `@` (at) • [[Dollar sign|`$` (dollar sign)]] • [[&|`&` (ampersand)]] • [[Hash|`#` (hash)]] • [['|`'` (single quote)]]
43+
44+_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)]]
5145
5246---
5347*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