제 5 장 변수, 바인딩, 식 및 제어문

36
5 5 제제 제제 , , 제제제 제제제 , , 제 제 제제제 제 제 제제제 변변 변변 ( Variables) Variables) 변변 변변 변변 변변 , , 변변 변변 ( attribute) attribute) 변 변변 변 변변 , , 변변 변변 ( reference), reference), ( value) value) 변 4 변변변 변변 변변변 변변 (ISO (ISO 변변 변변 ) 변변변변 변변변 변변 변변변 변 변변 변변 변변변변 변변변 변변 변변변 변 변변 변변 (Generally) (Generally) 변변변 변변변 ( identifiers) identifiers) 변변변 변변변 변변변 변변변 변변변 변변변 / 변변변 변변변 변변변변 변변변 변변 변변변 변변변 변변변변 변변변 변변 ( component) component) 변 변변변 변 변변변 변) X :=3.14159 X :=3.14159 변 변변 변 변변 변변 변변 ( 변변변 변변변 ) : : X 변변 변변 : : 변변변 변변변 , , 변변 변변 변변 변변 ( 변변 변변 ) : : 변변 변변변 변변 변변 변변변 변변 : : 3.14159 3.14159 < D.W. Barron D.W. Barron 변 변변 변변변 변 변변 변변변 > 변변 변변 변변 변변 변변 변변 ( 변변 변변 ) 변변 변변변 변변 변변변 변변 변변변 변변 변변변 X 변변 변변 3.14159 3.14159 변변변 변변변 4 변변 변변 변변 변변 (Component) (Component)

Upload: amela-velasquez

Post on 02-Jan-2016

48 views

Category:

Documents


0 download

DESCRIPTION

이름 속성 참조 ( 위치 ). 3.14159. X. 실수. 값. 정적 바인딩 동적 바인딩. < D.W. Barron 의 변수 표기법>. 제 5 장 변수, 바인딩, 식 및 제어문. 변수 ( Variables) 정의 이름 , 속성 ( attribute) 의 집합 , 참조 ( reference), 값 ( value) 의 4요소로 구성 (ISO 정의 ) 실행시간 저장된 값이 변경될 수 있는 객체 (Generally) 식별자 ( identifiers) - PowerPoint PPT Presentation

TRANSCRIPT

  • 5 , , (Variables) , (attribute) , (reference), (value) 4 (ISO ) (Generally)(identifiers) / (component) ) X :=3.14159 () : X : , () : : 3.14159 4 (Component)

  • Binding (name) ? . , const n = 5 ; n 5 var x : integer ; x x := 2 ; x 2 ( ) , , , , ,

  • : (dynamic binding)) , ) , ) : (static binding) , , ) , ,

    : , ) , ,

    , , ( )

  • () (Design) : ) (, , ) (, ) (N, W)

    4.1) Y := X + 10 x : () (,), () cf) in pascal () 10 : () () + : () () := : () (), , ( )

  • , ) FORTRAN VS. SNOBOL4 ( ) - Fortran , ( ) - Snobol4 ( ) () . , ( ), , ,

  • , ,

  • , , (Declarations) , , , , ,

    Algol integer array x[2:10], : : 1 : 9 : 2 ~ 10 : : X

  • , , (static type checking) (type specific operation) : (mixed operation) : cf) real X integer Y; ... X + Y ( ) 1) 2) Y (W) 3) , ,

  • (static type checking) : , , : : Fortran, Algol, PL/I, Cobol, Pascal (dynamic type checking) : , (flexibility) : , , : Lisp, APL, Snobol 4Algol, PL/I, Ada : real array x[m1:n1,m2:n2] : : default : Fortran (I~N), (I~N ), ,

  • , ,

  • , ,

  • Bliss : l-value r-value (.) A .B + .C B, C r-value A (A l-value) A B B l-value (B ) A , ,

  • A := expr 1) l-value (Fortran, C ) expr , A 1) r-value (APL ) expr , A expr (flexibility) , ,

  • , ,

  • , , ab=41)2)a,b,c = x1+x2, y1+y2, z1+z2;

    11

  • (Constant & Initialization) : Pascal, Ada, Fortran 77 (record, array) ? : , , ? : , ? (predefined constant) ?, ,

  • Pascal const , , ( ) true, false, maxint const pi = 3.14159; Algol68 (:=, =) real root2 := 1.414213 real root2 = 1.414213 , ,

  • () Ada constant ( ) Xconstant INTEGER :=17 YINTEGER :=17 type NATURAL is 1..N type ROSTER is array (NATURAL) of INTEGER LINEUPROSTER (1..100) LINEUP := (1..50=>1, 51..100=>-l) LINEUPROSTER (1..100) := (1..50=>1 , 51..100=>-l) & LINEUPconstant ROSTER (1..100) := (1..50=>1, 51..100=>-l) Fortran DATA ( ) PARAMETER ( , Fortran77 ), ,

  • (Expression)() : : (, , ) (referential transparency) : (side-effect) Cf) .. : , , implicit (default) or explicit () : left-to-right BNF (AST) , ,

  • , ,

  • , ,

  • , ,

  • (applicative order) operand1 op operand2 operand1, operand2 , op , :x 0 or y / x < 1 x 0 x 0 and y / x < 1 x 0 , x 0 , y / x overflow * or and (short circuit) :x cand y = if x then y else false x cor y = if x then true else y ADA - and then, or else , ,

  • (Condition Statements)FORTRAN : GOTO IF (BCOND) L1 , L2 : BCOND L1, L2 : IF (BCOND) : ( goto ) IF (ACOND) L1 , L2 , L3 : ACOND , 0, L1, L2, L3 Algol 60 : , dangling else if condition then S1 else S2 Fortran 77 dangling else ENDIF

    6.5 if if C1 then S1 else if C2 then S2 ........ else if Cn then Sn else Sn+1 endif endif endif, ,

  • Ada elsif 6.5 if C1 then S1 elsif C2 then S2 elsif C3 then S3 . . . . . . . . . . . elsif Cn then Sn else Sn+1 endif if endif ) Algol 68 elif( ), Ada elsif, ,

  • , , :

  • Ada other expression (range) case thismonth is when FebAprJun..Aug => birthday := 4; when Sep => birthday := 1; when others => birthday := 0; endcase;case (selector expression) ? case ? case case ? ? , ? ?, ,

  • (Iterative Statements), ,

  • , ,

  • for : ( ) ) Pascal, C, Ada, Algol for ) FORTRAN DO

    for ? , , ? ? ? ? ? ? (scope)?

    , ,

  • , ,

  • Pascal , (, ) , : to, downtoFortran II DO ( ) DO , , : Algol68 For E1, E2, E3 : , (Algol 60 , ) : (Ada ), , DO 30 I = 2, K Z=RAN(iseed) 30 F(I)=Z*(FMAX-FMIN)+FMIN

  • Java, C for for ( )

    , , ;;

    expr

  • GOTOGOTO (Label) , , , , 1) - (Fortran, Basic) 2) - - , , , - Algol , 1) 3) (Snobol4, APL) - - , , .READ X .GOTO X

  • GOTO GOTO GOTO ( , ) () GOTO : Fortran, Basic if GOTO IF pure LISP, Bliss : GOTO Pascal : Java : GOTO GOTO (, , )

    , ,

  • Programming Languages - The end of Chapter 5 - To Be Continue ...