2008. 3. 9. 13:51
@GSMC/서용덕: DMD Programming
statement (문장)
- A statement will have internal components (eg, expressions).
- Many languages (e.g. C) make a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier.
: An instruction written in a high-level language.
- Programs consist of statements and expressions. An expression is a group of symbols that represent a value.
- Statements do not return results and are executed solely for their side effects, while expressions always return a result and often do not have side effects at all.
Simple statements
* assignment: A := A + 1
* call: CLEARSCREEN()
* return: return 5;
* goto: goto 1
* assertion: assert(ptr != NULL);
Compound statements
* statement block: begin WRITE('Number? '); READLN(NUMBER); end
* if-statement: if A > 3 then WRITELN(A) else WRITELN("NOT YET") end
* switch-statement: switch (c) { case 'a': alert(); break; case 'q': quit(); break; }
* while-loop: while NOT EOF DO begin READLN end
* do-loop: do { computation(&i); } while (i < 10);
* for-loop: for A:=1 to 10 do WRITELN(A) end
* assignment: A := A + 1
* call: CLEARSCREEN()
* return: return 5;
* goto: goto 1
* assertion: assert(ptr != NULL);
Compound statements
* statement block: begin WRITE('Number? '); READLN(NUMBER); end
* if-statement: if A > 3 then WRITELN(A) else WRITELN("NOT YET") end
* switch-statement: switch (c) { case 'a': alert(); break; case 'q': quit(); break; }
* while-loop: while NOT EOF DO begin READLN end
* do-loop: do { computation(&i); } while (i < 10);
* for-loop: for A:=1 to 10 do WRITELN(A) end
expression (式)
: a combination of values, variables, operators, and functions
: any legal combination of symbols that represents a value
: 프로그래밍 작성 언어에서 어떤 값을 계산하는 숫자, 변수, 함수 호출 결과 및 이들이 연산자에 의해 조합된 것. 예를 들어 100, x, x+y, sin(y*2), y>100 등은 모두 식이다. 그 결과값의 형에 따라 산술식, 논리식, 문자열식 등이 있다.
- Each programming language and application has its own rules for what is legal and illegal.
- Every expression consists of at least one operand and can have one or more operators. Operands are values, whereas operators are symbols that represent particular actions.
- The expression is (or can be said to have) its evaluated value; the expression is a representation of that value.
- Expressions are often classified by the type of value that they represent. For example:
# Boolean expressions : Evaluate to either TRUE or FALSE
# integer expressions: Evaluate to whole numbers, like 3 or 100
# Floating-point expressions: Evaluate to real numbers, like 3.141 or -0.005
# String expressions: Evaluate to character strings
# integer expressions: Evaluate to whole numbers, like 3 or 100
# Floating-point expressions: Evaluate to real numbers, like 3.141 or -0.005
# String expressions: Evaluate to character strings
side effect
- a function or expression is said to produce a side effect if it modifies some state in addition to returning a value.
declaration (宣言)
- a declaration specifies a variable's dimensions, identifier, type, and other aspects. It is used to announce the existence of a variable or function.
- For variables, definitions assign bits to an area of memory that was reserved during the declaration phase. For functions, definitions supply the function body. It is thus clear that while a variable or function may be declared many times, it must only be defined once.
(1) 어떤 언어의 원시 프로그램에서 그 프로그램의 인터프리터에 필요한 정보, 특히 프로그램에서 실행 시 사용될 자료의 특성을 전달하기 위한 표현 방법.
(2) 프로그램에서 변수, 프로시저, 함수 등의 이름과 그 자료 유형, 함수의 반환값, 함수나 프로시저의 인자와 그 몸체를 정의하는 것. 특히 프로그램에서 쓰이는 변수의 형을 정의하는 것을 말한다.
ref. philphys informed:
http://en.wikibooks.org/wiki/Computer_programming#Common_concepts
http://en.wikibooks.org/wiki/Python_Programming
'@GSMC > 서용덕: DMD Programming' 카테고리의 다른 글
week 2 review (0) | 2008.03.15 |
---|---|
[Steve Oualline] 4. Basic Declarations and Expressions (0) | 2008.03.10 |
hw1 (0) | 2008.03.10 |
week 1 review - keywords & file I/O (0) | 2008.03.07 |
vi (0) | 2008.03.07 |