Sign in Join
Wiki copytemporary

Basic Pascal Tutorial/Chapter 1/Identifiers/ja: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
111B - 識別子 (著者: Tao Yue, 状態: 修正あり)
22
33識別子とは保存された値、たとえば変数や定数を参照するための名前である。また、プログラムも識別子によって識別されなくてはならない。
44
55識別子の規則:
66
7-```
7+```text
88 英語のアルファベットかアンダースコア(_)の文字ではじまらなくてはならない。
99 その後にはアルファベット・数字、あるいはアンダースコア(_)を続けることができる。
1010 以下のような特殊記号は含めてはならない。
1111```
1212
13-```
13+```text
1414~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
1515```
1616
1717目次 \[hide\]
1818
19-```
19+```text
2020 1 予約語
2121 1.1 Turbo Pascal の予約語
2222 1.2 Delphi の予約語
2323 1.3 Free Pascal の予約語
2424```
2525
2626## 予約語
2727
2828識別子の中には Pascal で予約されており、自分の識別子として利用できないものがある。FPC のリファレンスによれば、それらは次のようにグループ化される。
2929
30-```
30+```text
3131 Turbo Pascal の予約語
3232 Delphi の予約語
3333 FPC の予約語
3434```
3535
3636## Turbo Pascal の予約語
3737
3838| | | | | | | | |
3939|----|----|----|----|----|----|----|----|
4040| absolute | and | array | asm | begin | break | case | const |
4141| constructor | continue | destructor | div | do | downto | else | end |
4242| file | for | function | goto | if | implementation | in | inherited |
4343| inline | interface | label | mod | nil | not | object | of |
4444| on | operator | or | packed | procedure | program | record | reintroduce |
4545| repeat | self | set | shl | shr | string | then | to |
4646| type | unit | until | uses | var | while | with | xor |
4747
4848## Delphi の予約語
4949
5050The Delphi (II) の予約語は Pascal の予約語と同じものに加えて以下のものである。
5151
5252| | | | | | | |
5353|-----|---------|--------|----------|--------------|-----------|----------------|
5454| as | class | except | exports | finalization | finally | initialization |
5555| is | library | on | property | raise | threadvar | try |
5656
5757## Free Pascal の予約語
5858
5959Turbo Pascal と Delphi の予約語に、Free Pascal はまた予約語として以下のものを含む。
6060
6161| | | | | |
6262|---------|------|-------|-----|------|
6363| dispose | exit | false | new | true |
6464
6565また、Pascal には事前に定義された識別子がある。それらを自分自身の定義と置き換えることはできるが、 Pascal の機能の一部は除かれてしまう。
6666
6767| | | | | | | | |
6868|-------|-------------|---------|---------|------|---------|--------|------|
6969| abs | arctan | boolean | char | cos | dispose | eof | eoln |
7070| exp | false | input | integer | ln | maxint | new | odd |
7171| ord | output | pack | page | pred | read | readln | real |
7272| reset | rewrite | round | sin | sqr | sqrt | succ | text |
7373| true | trunc write | writeln | | | | | |
7474
7575Pascal は大文字、小文字を区別しない! MyProgram、MYPROGRAM と mYpRoGrAm は同じになる。しかし、可読性を上げるために意味があるように大文字を使用した方がよいだろう!
7676
7777識別子はどんな長さでもよいが、多くの Pascal コンパイラは最初の32文字(あるいはそれぐらい)だけを見る。つまり、以下の2つは、32文字以降しか違わないので Pascal コンパイラには同じものと見なされるかもしれない。
7878
79-```
79+```text
8080 ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta
8181 ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta
8282```
8383
8484すべてのコンパイラで互換性を持たせるためには識別子は無理のない長さ、せいぜい15文字までにした方がよい。そうすることでタイプする手間も省けるだろう。
8585
8686| | | |
8787|----|----|----|
8888| [[Basic Pascal Tutorial/Chapter 1/Program Structure/ja|previous]] | [[Basic Pascal Tutorial/Contents/ja|contents]] | [[Basic Pascal Tutorial/Chapter 1/Constants/ja|next]] |
8989
9090---
9191*From the Free Pascal wiki, page "Basic Pascal Tutorial/Chapter 1/Identifiers/ja", 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).*

Back to history