Difference between revisions of "Basic Pascal Tutorial/Chapter 1/Identifiers/ja"

From Lazarus wiki
Jump to navigationJump to search
(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 ...")
 
Line 1: Line 1:
1B - Identifiers (author: Tao Yue, state: changed)
+
1B - 識別子 (著者: Tao Yue, 状態: 修正あり)
  
Identifiers are names that allow you to reference stored values, such as variables and constants. Also, every program must be identified (get it?) by an identifier.
+
識別子とは保存された値、たとえば変数や定数を参照するための名前である。また、プログラムはある識別子によって識別されなくてはならない(あるいは識別子を得なくてはならない?)。
  
Rules for identifiers:
+
識別子の規則:
  
     Must begin with a letter from the English alphabet or an underscore (_).
+
     英語のアルファベットかアンダースコア(_)の文字ではじまらなくてはならない。
     Can be followed by alphanumeric characters (alphabetic characters and numerals), or the underscore (_).
+
     その後にはアルファベット・数字、あるいはアンダースコア(_)を続けることができる。
     May not contain special characters, such as:
+
     以下のような特殊記号は含めてはならない。
  
 
  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
 
  ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \
  
Contents [hide]  
+
目次 [hide]  
  
     1 Reserved words
+
     1 リザーブ単語
         1.1 Turbo Pascal reserved words
+
         1.1 Turbo Pascal のリザーブ単語
         1.2 Delphi reserved words
+
         1.2 Delphi のリザーブ単語
         1.3 Free Pascal reserved words
+
         1.3 Free Pascal のリザーブ単語
 +
 
 +
 
 +
== リザーブ単語 ==
  
[edit] Reserved words
 
  
 
Several identifiers are reserved in Pascal -- you cannot use them as your own identifiers. According to the FPC Reference they are grouped in:
 
Several identifiers are reserved in Pascal -- you cannot use them as your own identifiers. According to the FPC Reference they are grouped in:

Revision as of 08:31, 8 July 2015

1B - 識別子 (著者: Tao Yue, 状態: 修正あり)

識別子とは保存された値、たとえば変数や定数を参照するための名前である。また、プログラムはある識別子によって識別されなくてはならない(あるいは識別子を得なくてはならない?)。

識別子の規則:

   英語のアルファベットかアンダースコア(_)の文字ではじまらなくてはならない。
   その後にはアルファベット・数字、あるいはアンダースコア(_)を続けることができる。
   以下のような特殊記号は含めてはならない。 
~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \

目次 [hide]

   1 リザーブ単語
       1.1 Turbo Pascal のリザーブ単語
       1.2 Delphi のリザーブ単語
       1.3 Free Pascal のリザーブ単語


リザーブ単語

Several identifiers are reserved in Pascal -- you cannot use them as your own identifiers. According to the FPC Reference they are grouped in:

   Turbo Pascal reserved words
   Delphi reserved words
   FPC reserved words 

[edit] Turbo Pascal reserved words 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 [edit] Delphi reserved words

The Delphi (II) reserved words are the same as the pascal ones, plus the following ones: as class except exports finalization finally initialization is library on property raise threadvar try [edit] Free Pascal reserved words

On top of the Turbo Pascal and Delphi reserved words, Free Pascal also considers the following as reserved words: dispose exit false new true

Also, Pascal has several pre-defined identifiers. You can replace them with your own definitions, but then you'd be deleting part of the functionality of 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 is not case sensitive! MyProgram, MYPROGRAM, and mYpRoGrAm are equivalent. But for readability purposes, it is a good idea to use meaningful capitalization!

Identifiers can be any length, but many Pascal compilers will only look at the first 32 characters or so. That is,

   ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta
   ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta

may be equivalent to some Pascal compilers because the differences begin in the 33rd character.

To make your code compilable by all compilers, use a reasonable length for identifiers -- up to 15 characters. That way, you'll also save on typing.