Plus: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 1 | + | + | |
| 2 | 2 | ||
| 3 | - | ||
| 3 | + | The symbol `+` (pronounced “plus”) is used to: | |
| 4 | 4 | ||
| 5 | - | ||
| 6 | - | ||
| 7 | - | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 5 | + | * explicitly indicate the positive sign of a number, | |
| 6 | + | * add two numbers resulting to a number, | |
| 7 | + | * form a union of [[Set|sets]], | |
| 8 | + | * (FPC) concatenate two strings (or characters; except [[PChar|`pchar`]]). | |
| 9 | + | * if `{$modeSwitch arrayOperators+}` (default in [[Mode Delphi|`{$mode Delphi}`]]), concatenate arrays (since FPC 3.2.0) | |
| 10 | + | * enable a feature in a `{$modeSwitch}` | |
| 11 | 11 | ||
| 12 | - | ||
| 12 | + | ``` | |
| 13 | 13 | program plusDemo(input, output, stderr); | |
| 14 | - | ||
| 15 | - | ||
| 16 | - | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | 14 | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 15 | + | var | |
| 16 | + | x: longint; | |
| 17 | + | g: set of (foo, bar); | |
| 18 | + | m: string; | |
| 19 | + | begin | |
| 20 | + | // unary operator: positive sign | |
| 21 | + | x := +7; // x becomes positive 7 | |
| 22 | + | x := +$100; // x becomes 256 | |
| 23 | + | // (dollar sign denotes hexadecimal base) | |
| 24 | + | ||
| 25 | + | // addition | |
| 26 | + | x := 7 + 7; // x becomes 14 | |
| 27 | + | x := 7 + 7 + 7 + 7 + 7 + 7; // x becomes 42 | |
| 28 | + | ||
| 29 | + | // union of sets | |
| 30 | + | g := [foo] + [bar]; // g becomes [foo, bar] | |
| 31 | + | ||
| 32 | + | // concatenation of strings and/or characters (FPC/Delphi extension) | |
| 33 | + | m := 'Hello ' + 'world!'; // m becomes 'Hello world!' | |
| 34 | + | end. | |
| 35 | 35 | ``` | |
| 36 | 36 | ||
| 37 | - | ||
| 37 | + | The plus sign is also a unary operator. One can write such stupid expressions as `++++++++++++++42` which will evaluate to positive 42. | |
| 38 | 38 | ||
| 39 | - | ||
| 39 | + | In [[ASCII]], the character code decimal `43` (or [[Hexadecimal|hexadecimal]] `2B`) is defined to be `+` (plus sign). | |
| 40 | 40 | ||
| 41 | 41 | ## see also | |
| 42 | 42 | ||
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 43 | + | * [`system.add`](<https://www.freepascal.org/docs-html/rtl/system/.op-add-variant-ariant-ariant.html>) | |
| 44 | + | * [`system.concat`](<https://www.freepascal.org/docs-html/rtl/system/concat.html>) returns concatenation of strings | |
| 45 | + | * [`strings.strcat`](<https://www.freepascal.org/docs-html/rtl/strings/strcat.html>) returns concatenation of [[PChar|`pchar`]] strings | |
| 46 | 46 | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + | **navigation bar: topic: Pascal symbols** | |
| 50 | + | ||
| 51 | + | _single characters:_ `+` (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)]] | |
| 52 | + | ||
| 53 | + | _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)]] | |
| 54 | + | ||
| 47 | 55 | --- | |
| 48 | - | ||
| 56 | + | *From the Free Pascal wiki, page "Plus", as the Internet Archive kept it on 2024-09-20, last changed on 2019-10-17. 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).* |
