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

From Lazarus wiki
Jump to navigationJump to search
m (Kai Burghardt moved page Identifiers/ko to Basic Pascal Tutorial/Chapter 1/Identifiers/ko: tidy up main name space: create subpage hierarchy for basic Pascal tutorial [cf. [[Special: PermaLink/149778#...)
(bypass redirects [cf. discussion])
Line 79: Line 79:
  
 
{|style=color-backgroud="white" cellspacing="20"
 
{|style=color-backgroud="white" cellspacing="20"
|[[Program_Structure/ko|previous]]   
+
|[[Basic Pascal Tutorial/Chapter 1/Program Structure/ko|previous]]   
 
|[[Contents/ko|contents]]  
 
|[[Contents/ko|contents]]  
|[[Constants/ko|next]]
+
|[[Basic Pascal Tutorial/Chapter 1/Constants/ko|next]]
 
|}
 
|}

Revision as of 01:15, 6 August 2022

български (bg) Deutsch (de) English (en) français (fr) italiano (it) 日本語 (ja) 한국어 (ko) русский (ru) 中文(中国大陆)‎ (zh_CN)

1B - 식별자 (저자: Tao Yue, 상태: 변경)

식별자란 변수나 상수 같이 저장된 값을 참조하는 이름을 말한다. 또한 모든 프로그램은 또한 식발자로 지정이 되어야 한다. (이해가 되는가?)

식별자를 위한 규칙:

  • 반드시 영문자 또는 밑줄 (_)로 시작해야 한다.
  • 그 이후엔 알파벳 또는 숫자, 또는 밑줄 (_)이 사용될 수 있다.
  • 다른 특수문자는 사용할 수 없다. 예를 들자면,
 ~ ! @ # $ % ^ & * ( ) + ` - = { } [ ] : " ; ' < > ? , . / | \

예약된 단어들

몇몇 식별자는 파스칼에서 예약되어있어, 사용자가 사용할 수 없다. FPC 참고서에 따르면, 다음과 같이 묶어 구분한다.

  • 터보 파스칼 예약어
  • 델파이 예약어
  • 프리 파스칼 컴파일러 (FPC) 예약어

터보 파스칼 예약어

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

델파이 예약어

델파이 예약어는 파스칼과 같으며, 거기에 아래와 같은 것들이 추가되었다.

as class except exports finalization finally initialization
is library on property raise threadvar try

프리 파스칼 예약어

터보 파스칼과 델파이 예약어에 더해, 프리 파스칼은 다음과 같은 예약어를 추가로 갖는다.

dispose exit false new true

또한, 파스칼은 기 정의된 예약어를 갖고 있는데, 사용자에 따라 재정의하여 사용할 수 있다. 그러나, 그렇게 할 경우 파스칼의 일부 기능을 사용할 수 없을 수도 있다.

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

파스칼의 경우 대소문자를 구분하지 않는다! MyProgram, MYPROGRAM, 그리고 mYpRoGrAm 은 모두 같은 것으로 취급된다. 그러나, 가독성을 위해, 대소문자를 적절하게 사용하는 것이 좋을 것이다!

식별자의 길이는 자유롭게 사용할 수 있지만, 많은 파스칼 컴파일러는 첫 32 문자만을 사용한다. 그러므로,

    ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFAlphaBeta
    ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGammaDelta

이 두개의 식별자는 몇몇 파스칼 컴파일러에서 같은 것으로 취급한다. 왜냐하면 두 식별자의 차이는 33번째 문자에서 나타나기 시작했기 때문이다.

모든 컴파일러에서 컴파일 되게 하기 위해선, 적절한 길이로 식별자를 사용해야 한다. 아마도 한 15자 정도... 그럼으로써 타이핑하는 시간도 절약할 수 있다.

previous contents next