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 ...


Top Related