&/pt: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | 1 | & | |
| 4 | - | ||
| 5 | - | ||
| 6 | 2 | ||
| 7 | 3 | Em [[ASCII/pt|ASCII]], o caractere de código decimal `38` (ou em [[Hexadecimal/pt|$]]`26`) é, por definição, `&` (chamado de “E comercial”). | |
| 8 | 4 | ||
| 9 | 5 | ## Pascal | |
| 10 | 6 | ||
| 11 | 7 | ### Base octal | |
| 12 | 8 | ||
| 13 | 9 | Em [[Pascal/pt|Pascal]] o `&` denota um número em base octal. | |
| 14 | 10 | ||
| 15 | 11 | ``` pascal | |
| 16 | 12 | program messageNo(input, output, stderr); | |
| 17 | 13 | ||
| 18 | 14 | uses | |
| 19 | 15 | baseUnix; | |
| 20 | 16 | ||
| 21 | 17 | begin | |
| 22 | 18 | // withdraw group write access to current terminal | |
| 23 | 19 | // equivalent to invoking: mesg n | |
| 24 | 20 | fpChmod('/dev/stdin', &0600); | |
| 25 | 21 | end. | |
| 26 | 22 | ``` | |
| 27 | 23 | ||
| 28 | 24 | In an octal base only the characters `0` through and including `7` are allowed. An optional sign is specified in front of the `&`. | |
| 29 | 25 | ||
| 30 | 26 | As a passing remark, in a production program the number in the above example is better written as | |
| 31 | 27 | ||
| 32 | 28 | ``` pascal | |
| 33 | 29 | fpChmod('/dev/stdin', S_IRUSR or S_IWUSR); | |
| 34 | 30 | ``` | |
| 35 | 31 | ||
| 36 | 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. | |
| 37 | 33 | ||
| 38 | 34 | > **Note:** Literais numéricos em octal não são suportados pelos modos [[Mode Delphi/pt|{$mode Delphi}]] e [[Mode TP/pt|{$mode TP}]]. | |
| 39 | 35 | ||
| 40 | 36 | ### Caractere de escape | |
| 41 | 37 | ||
| 42 | 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. | |
| 43 | 39 | ||
| 44 | 40 | ## Lazarus | |
| 45 | 41 | ||
| 46 | 42 | No [[Lazarus/pt|Lazarus]] o `&` é usado para | |
| 47 | 43 | ||
| 48 | 44 | - indicar teclas de atalho em [[TMenuItem]] | |
| 49 | 45 | ||
| 50 | 46 | --- | |
| 51 | 47 | *From the Free Pascal wiki, page "&/pt", 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).* |
