Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Identifiers/zh CN: what changed

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

Title: Basic Pascal Tutorial/Chapter 1/Identifiers/zh CN

OldNewLine
1+1B - 标识符 (原作者: Tao Yue, 状态: 已更改)
2+
3+标识符是一些名字,用于引用存储的值,例如变量和常量。同样,每个程序都必须被一个标识符标识(明白?)。
4+
5+标识符命名的规则:
6+
7+- 必须以一个英文字母或者下划线(_)开始。
8+- 后面可以是英文字母,数字或者下划线(_).
9+- 不能含有如下特殊字符:
10+
11+``  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \ ``
12+
13+# 保留字
14+
15+有几个标识符是被Pascal已经占用的,你不能将他们用作你自定义的标识符。 根据[FPC参考](http://lazarus-ccr.sourceforge.net/fpcdoc/ref/ref.html),他们分为如下三类:
16+
17+- Turbo Pascal保留字
18+- Delphi 保留字
19+- FPC 保留字
20+
21+### Turbo Pascal保留字
22+
23+| | | | | | | | |
24+|----|----|----|----|----|----|----|----|
25+| absolute | and | array | asm | begin | break | case | const |
26+| constructor | continue | destructor | div | do | downto | else | end |
27+| file | for | function | goto | if | implementation | in | inherited |
28+| inline | interface | label | mod | nil | not | object | of |
29+| on | operator | or | packed | procedure | program | record | reintroduce |
30+| repeat | self | set | shl | shr | string | then | to |
31+| type | unit | until | uses | var | while | with | xor |
32+
33+### Delphi 保留字
34+
35+Delphi(II)保留字跟Turbo Pascal一样,但是增加了如下内容:
36+
37+| | | | | | | |
38+|-----|---------|--------|----------|--------------|-----------|----------------|
39+| as | class | except | exports | finalization | finally | initialization |
40+| is | library | on | property | raise | threadvar | try |
41+
42+### Free Pascal 保留字
43+
44+除了拥有Turbo Pascal和Delphi的保留字之外,Free Pascal还增加了下面的保留字:
45+
46+| | | | | |
47+|---------|------|-------|-----|------|
48+| dispose | exit | false | new | true |
49+
50+另外,Pascal有几个预先定义的标识符。你可以用你自己的定义来覆盖他们,但这样做你就没法使用这些标识符在Pascal中原来所具有的功能了。
51+
52+| | | | | | | | |
53+|-------|-------------|---------|---------|------|---------|--------|------|
54+| abs | arctan | boolean | char | cos | dispose | eof | eoln |
55+| exp | false | input | integer | ln | maxint | new | odd |
56+| ord | output | pack | page | pred | read | readln | real |
57+| reset | rewrite | round | sin | sqr | sqrt | succ | text |
58+| true | trunc write | writeln | | | | | |
59+
60+Pascal是不区分大小写的!MyProgram,MYPROGRAM和mYpRoGrAm这三者是完全相同的。但为了可读性考虑,最好有意义地使用大小写!
61+
62+标识符长度可以是任意的,但是许多Pascal编译器实际上只看开头的大约32个字符。也就是说,下面两个标识符:
63+
64+`    ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta`\
65+`    ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta`
66+
67+可能对于某些编译器来说它们两者是相同的,因为第一个不同之处出现在第33个字符。
68+
69+为了让你的代码兼容所有的编译器,使用合理长度的标识符——最多15个字符。这样,你打字的时候也省事。
70+
71+| | | |
72+|----|----|----|
73+| [[Basic Pascal Tutorial/Chapter 1/Program Structure/zh CN|上一页]] | [[Basic Pascal Tutorial/Contents/zh CN|目录]] | [[Basic Pascal Tutorial/Chapter 1/Constants/zh CN|下一页]] |
74+
75+---
76+*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Identifiers/zh CN", as it stood on 2022-08-20 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).*
77+Category: zh

Back to history