Sign in Join
Wiki copytemporary

&: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: &

OldNewLine
1+&
2+
3+In [[ASCII]] the character code decimal `38` (or [[Hexadecimal|$]]`26`) is defined to be `&` (pronounced “ampersand”).
4+
5+## Pascal
6+
7+### octal base
8+
9+In [[Pascal]] the `&` denotes an octal base number.
10+
11+``` pascal
12+program messageNo(input, output, stderr);
13+
14+uses
15+ baseUnix;
16+
17+begin
18+ // withdraw group write access to current terminal
19+ // equivalent to invoking: mesg n
20+ fpChmod('/dev/stdin', &0600);
21+end.
22+```
23+
24+In an octal base only the characters `0` through and including `7` are allowed. An optional sign is specified in front of the `&`.
25+
26+As a passing remark, in a production program the number in the above example is better written as
27+
28+``` pascal
29+fpChmod('/dev/stdin', S_IRUSR or S_IWUSR);
30+```
31+
32+since it is more meaningful than having a raw number. Pascal is a high-level language. Use this advantage. Write what you *mean*, not what in fact the computer does.
33+
34+> **Note:** Octal number literals are not supported in [[Mode Delphi|{$mode Delphi}]] and [[Mode TP|{$mode TP}]].
35+
36+### identifier escape
37+
38+[[FPC|FreePascal]] retroactively declared some new [[Reserved word|reserved words]]. In order of being capable of compiling old code with an up-to-date [[Compiler|compiler]] version, which might fail due to those new reserved words, FPC declared the `&` as an escape character. Thus, without refactoring the code but escaping, i.e. prepending an `&` to the [[Identifier|identifier]], the compiler accepts the actual reserved word as a valid identifier. New code though shall come up with different identifier names, without utilizing this feature.
39+
40+## Lazarus
41+
42+In [[Lazarus]] the `&` is used to
43+
44+- indicate shortcut keys in [[TMenuItem]]
45+
46+---
47+*From the Free Pascal wiki, page "&", as it stood on 2022-08-06 after a change by Kai Burghardt, 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).*

Back to history