&/pt

From Lazarus wiki
Jump to navigationJump to search

English (en) suomi (fi) français (fr) português (pt) русский (ru)

&

Em ASCII, o caractere de código decimal 38 (ou em $26) é, por definição, & (chamado de “E comercial”).

Pascal

Base octal

Em Pascal o & denota um número em base octal.

program messageNo(input, output, stderr);

uses
	baseUnix;

begin
	// withdraw group write access to current terminal
	// equivalent to invoking: mesg n
	fpChmod('/dev/stdin', &0600);
end.

In an octal base only the characters 0 through and including 7 are allowed. An optional sign is specified in front of the &.

As a passing remark, in a production program the number in the above example is better written as

fpChmod('/dev/stdin', S_IRUSR or S_IWUSR);

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.

Light bulb  Nota: Literais numéricos em octal não são suportados pelos modos {$mode Delphi} e {$mode TP}.

Caractere de escape

FreePascal retroactively declared some new reserved words. In order of being capable of compiling old code with an up-to-date 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, 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.

Lazarus

No Lazarus o & é usado para


navigation bar: topic: Pascal symbols
single characters

+ (plus)  •  - (minus)  •  * (asterisk)  •  / (slash)
= (equal)  •  > (greater than)  •  < (less than)
. (period)  •  : (colon)  •  ; (semi colon)
^ (hat)  •  @ (at)
$ (dollar sign)  •  & (ampersand)  •  # (hash)
' (single quote)

character pairs

<> (not equal)  •  <= (less than or equal)  •  := (becomes)  •  >= (greater than or equal)

 •  >< (symmetric difference)  •  // (double slash)