Difference between revisions of "Basic Pascal Tutorial/Chapter 1/Identifiers/ja"
(Created page with "1B - Identifiers (author: Tao Yue, state: changed) Identifiers are names that allow you to reference stored values, such as variables and constants. Also, every program must ...") |
m (bypass language bar/categorization template redirect [cf. discussion]) |
||
(12 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{Basic Pascal Tutorial/Chapter 1/Identifiers}} | |
− | + | 1B - 識別子 (著者: Tao Yue, 状態: 修正あり) | |
− | + | 識別子とは保存された値、たとえば変数や定数を参照するための名前である。また、プログラムも識別子によって識別されなくてはならない。 | |
− | + | 識別子の規則: | |
− | + | ||
− | + | 英語のアルファベットかアンダースコア(_)の文字ではじまらなくてはならない。 | |
+ | その後にはアルファベット・数字、あるいはアンダースコア(_)を続けることができる。 | ||
+ | 以下のような特殊記号は含めてはならない。 | ||
~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \ | ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \ | ||
− | + | 目次 [hide] | |
− | 1 | + | 1 予約語 |
− | 1.1 Turbo Pascal | + | 1.1 Turbo Pascal の予約語 |
− | 1.2 Delphi | + | 1.2 Delphi の予約語 |
− | 1.3 Free Pascal | + | 1.3 Free Pascal の予約語 |
− | |||
− | + | == 予約語 == | |
− | |||
− | |||
− | |||
− | + | 識別子の中には Pascal で予約されており、自分の識別子として利用できないものがある。FPC のリファレンスによれば、それらは次のようにグループ化される。 | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Turbo Pascal の予約語 | |
− | + | Delphi の予約語 | |
− | + | FPC の予約語 | |
− | |||
− | |||
− | |||
− | + | == Turbo Pascal の予約語 == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | {| style="font-weight:bold; background-color:#f5f5f5" cellspacing=5 | |
+ | |absolute || and || array || asm || begin || break || case || const | ||
+ | |- | ||
+ | |constructor||continue || destructor || div || do || downto||else || end | ||
+ | |- | ||
+ | | file || for || function || goto || if||implementation ||in ||inherited | ||
+ | |- | ||
+ | | inline || interface || label || mod || nil || not || object|| of | ||
+ | |- | ||
+ | | on || operator || or || packed || procedure || program || record || reintroduce | ||
+ | |- | ||
+ | | repeat || self || set || shl || shr || string || then || to | ||
+ | |- | ||
+ | | type || unit || until || uses || var || while || with || xor | ||
+ | |} | ||
− | + | == Delphi の予約語 == | |
+ | |||
+ | The Delphi (II) の予約語は Pascal の予約語と同じものに加えて以下のものである。 | ||
+ | {| style="font-weight:bold; background-color:#f5f5f5" cellspacing=5 | ||
+ | | as || class || except || exports || finalization || finally || initialization | ||
+ | |- | ||
+ | | is || library || on || property || raise || threadvar || try | ||
+ | |} | ||
+ | |||
+ | == Free Pascal の予約語 == | ||
+ | |||
+ | |||
+ | Turbo Pascal と Delphi の予約語に、Free Pascal はまた予約語として以下のものを含む。 | ||
+ | {| style="font-weight:bold; background-color:#f5f5f5" cellspacing=5 | ||
+ | | dispose || exit || false || new || true | ||
+ | |} | ||
+ | |||
+ | また、Pascal には事前に定義された識別子がある。それらを自分自身の定義と置き換えることはできるが、 Pascal の機能の一部は除かれてしまう。 | ||
+ | {| style="font-weight:bold; background-color:#f5f5f5" cellspacing=5 | ||
+ | |abs ||arctan ||boolean ||char ||cos ||dispose ||eof ||eoln | ||
+ | |- | ||
+ | |exp ||false ||input ||integer ||ln ||maxint ||new ||odd | ||
+ | |- | ||
+ | |ord ||output ||pack ||page ||pred ||read ||readln ||real | ||
+ | |- | ||
+ | |reset ||rewrite ||round ||sin ||sqr ||sqrt ||succ ||text | ||
+ | |- | ||
+ | |true ||trunc write ||writeln | ||
+ | |} | ||
+ | |||
+ | Pascal は大文字、小文字を区別しない! MyProgram、MYPROGRAM と mYpRoGrAm は同じになる。しかし、可読性を上げるために意味があるように大文字を使用した方がよいだろう! | ||
+ | |||
+ | 識別子はどんな長さでもよいが、多くの Pascal コンパイラは最初の32文字(あるいはそれぐらい)だけを見る。つまり、以下の2つは、32文字以降しか違わないので Pascal コンパイラには同じものと見なされるかもしれない。 | ||
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta | ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta | ||
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta | ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta | ||
− | + | すべてのコンパイラで互換性を持たせるためには識別子は無理のない長さ、せいぜい15文字までにした方がよい。そうすることでタイプする手間も省けるだろう。 | |
+ | |||
− | + | {|style=color-backgroud="white" cellspacing="20" | |
+ | |[[Basic Pascal Tutorial/Chapter 1/Program Structure/ja|previous]] | ||
+ | |[[Basic Pascal Tutorial/Contents/ja|contents]] | ||
+ | |[[Basic Pascal Tutorial/Chapter 1/Constants/ja|next]] | ||
+ | |} |
Latest revision as of 16:16, 20 August 2022
│
български (bg) │
Deutsch (de) │
English (en) │
français (fr) │
italiano (it) │
日本語 (ja) │
한국어 (ko) │
русский (ru) │
中文(中国大陆) (zh_CN) │
1B - 識別子 (著者: Tao Yue, 状態: 修正あり)
識別子とは保存された値、たとえば変数や定数を参照するための名前である。また、プログラムも識別子によって識別されなくてはならない。
識別子の規則:
英語のアルファベットかアンダースコア(_)の文字ではじまらなくてはならない。 その後にはアルファベット・数字、あるいはアンダースコア(_)を続けることができる。 以下のような特殊記号は含めてはならない。
~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
目次 [hide]
1 予約語 1.1 Turbo Pascal の予約語 1.2 Delphi の予約語 1.3 Free Pascal の予約語
予約語
識別子の中には Pascal で予約されており、自分の識別子として利用できないものがある。FPC のリファレンスによれば、それらは次のようにグループ化される。
Turbo Pascal の予約語 Delphi の予約語 FPC の予約語
Turbo Pascal の予約語
absolute | and | array | asm | begin | break | case | const |
constructor | continue | destructor | div | do | downto | else | end |
file | for | function | goto | if | implementation | in | inherited |
inline | interface | label | mod | nil | not | object | of |
on | operator | or | packed | procedure | program | record | reintroduce |
repeat | self | set | shl | shr | string | then | to |
type | unit | until | uses | var | while | with | xor |
Delphi の予約語
The Delphi (II) の予約語は Pascal の予約語と同じものに加えて以下のものである。
as | class | except | exports | finalization | finally | initialization |
is | library | on | property | raise | threadvar | try |
Free Pascal の予約語
Turbo Pascal と Delphi の予約語に、Free Pascal はまた予約語として以下のものを含む。
dispose | exit | false | new | true |
また、Pascal には事前に定義された識別子がある。それらを自分自身の定義と置き換えることはできるが、 Pascal の機能の一部は除かれてしまう。
abs | arctan | boolean | char | cos | dispose | eof | eoln |
exp | false | input | integer | ln | maxint | new | odd |
ord | output | pack | page | pred | read | readln | real |
reset | rewrite | round | sin | sqr | sqrt | succ | text |
true | trunc write | writeln |
Pascal は大文字、小文字を区別しない! MyProgram、MYPROGRAM と mYpRoGrAm は同じになる。しかし、可読性を上げるために意味があるように大文字を使用した方がよいだろう!
識別子はどんな長さでもよいが、多くの Pascal コンパイラは最初の32文字(あるいはそれぐらい)だけを見る。つまり、以下の2つは、32文字以降しか違わないので Pascal コンパイラには同じものと見なされるかもしれない。
ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta
すべてのコンパイラで互換性を持たせるためには識別子は無理のない長さ、せいぜい15文字までにした方がよい。そうすることでタイプする手間も省けるだろう。
previous | contents | next |