Sign in Join
Wiki copytemporary

Colon: what changed

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

Title: Colon

OldNewLine
1+<div style="float:right; margin: 0 25px 20px 0; padding:50px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">
2+
3+
4+</div>
5+
6+The symbol `:`, pronounced “colon”, is used in [[Pascal]] in several ways:
7+
8+- in an [[Identifier|identifier]] declaration it separates the [[Type|type]]
9+ - most notably in [[Var|var]] sections
10+ - but also in [[Const|const]] sections (in case of *explicitely* typed constants)
11+ - [[Procedure|procedure]] and [[Function|function]] parameters have a type, too
12+ - and return values of functions (including operator overloads)
13+ - as well as [[Property|properties]]
14+ - in general, everywhere where a new identifier associated with some memory, is introduced (also custom structured type definitions)
15+- in [[Case|case]] selectors it closes a match-list
16+- in [[Label|label]] definitions the colon seperates the instruction from the label name
17+- also some routines, especially the [[Str]], [[Write|write]] and `writeLn` procedures accept further parameters via colon separated arguments
18+- Offset / segment separation under DOS `Mem[$B800:$0000]`
19+
20+The following example shows the most prevalent usage scenarios:
21+
22+``` pascal
23+program colonDemo(input, output, stderr);
24+
25+procedure numberReport(const i: int64);
26+begin
27+ case i of
28+ low(i)..-1:
29+ begin
30+ writeLn('Your number is negative. ☹');
31+ end;
32+ 1..high(i):
33+ begin
34+ // right aligns to a width of 24 characters
35+ writeLn(i:24);
36+ end;
37+ else
38+ begin
39+ writeLn('You''ve entered zero.');
40+ end;
41+ end;
42+end;
43+
44+var
45+ i: int64;
46+
47+begin
48+ writeLn('Enter a number:');
49+ readLn(i);
50+ numberReport(i);
51+end.
52+```
53+
54+## other remarks
55+
56+- Colon appears in the assignment operator [[Becomes|:=]].
57+- In [[ASCII]] the character colon `:` has the value `58`.
58+
59+---
60+*From the Free Pascal wiki, page "Colon", 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).*
61+Category: Code

Back to history