1. 因為CONST的var沒有type,那我們使用CONST時要怎麼檢查呢? 也就是,我們用name eq. ,但CONST卻沒有type name? Ans: CONST is just like a C #define name string, where strings must be legal constants. 2. SWAP兩個array的時候(A <-> B, A[3..5],B[3..5]),那是array的所有element的值都要swap嗎? 也就是 A <-> B; 和 A[3] <-> B[3]; A[4] <-> B[4]; A[5] <-> B[5]; 同義嗎? Ans: Yes. 3. proc./func.可以這樣: PROCEDURE F(XXXXX,XXXXX,XXXXX) 也可以這樣 PROCEDURE F() 也可以這樣 PROCEDURE F 那call的時候,也是這樣嗎? 可以有一行寫成 F; 嗎? Ans: You need to use F() when a procedure is called. "F;" is invalid for calling a procedure named F. 4.SPEC.的p.10,第一段關於PROCEDURE的地方似乎有問題;應該也不能在:=右邊吧? Ans: Yes, you are right. A procedure can only be called and as a procedure call statement by itself. 5. SPEC.的p.10,第三段關於p/f-name的地方,可以解釋成: 只要我能夠call的proc/func,我都不能再decalre一個 var/proc name/func name和他一樣嗎?還是說只是在"該層"scope而已? Ans: 只是在"該層"scope而已. 6. WRITE(a, b, c); 可以接一長串 list 那中間需要印換行或空白之類的嗎? 不然 a = 1, b = 2, c = 3 WRITE(a, b, c) 印出來會是 123 好像不太合道理 Ans: There is one blank in between the write-out of two variables. 例如說: WRITE(a,b,c) 的結果 (若a=1 b=2 c=3) 是 1 2 3 7. 請問 FAQ #1 中說 const is just like C #define 那是不是代表 const 不需要進 symbol table (也就是說不會跟別的 variable/procedure/function name 衝突到) ? Ans: It acts like a C #define, but not exactly the same. Constant names need to be entered into symbol table. Constant names cannot be the same with other names used in the same scope. 8. 我想請問array[a,b,c]中 a,b,c除了可以是constant和variable外,是否可能是 expression 例如: array[(i+1)/2] 是否合法? Ans: In definition, each array lower and upper bound must be a constant. In computation, each index can be a legal integer expression. 9. 請問 array element可以和一般的variable swap 嗎? 例如 a : INTEGER; b : ARRAY[0..3] OF INTEGER; a <-> b[2]是否合法? Ans: Both of them are integers, so it can be swapped. 10. array 是否一定要一樣的結構才能全部swap 例如: b : ARRAY[0..3] OF INTEGER; a : ARRAY[1..4] OF INTEGER; 可以swap(a <-> b)嗎? 如果一大一小是不是就一定不能swap? 例如: b : ARRAY[0..3] OF INTEGER; a : ARRAY[0..5] OF INTEGER; Ans: Both of them are illegal. We are using name equivanlence. So none of them are type equivalent. 11. 請問在 IF boolean-expression THEN statement/ block of statements ENDIF; 語法中 (1) boolean-expression後是否一定有換行 ? (2) THEN之後是否一定有換行 ? (3) statement/ block of statements是否指只有可能是單行statement 或是"一個" block of statements ? 還是說有可能多行statements夾雜blocks ? Ans: (1) Yes. (2) Yes. (3) It means a single statment or a block of statments enclosed by BEGIN and END. Example: IF a > 3 THEN a := a + 3; ENDIF; IF b > 3 THEN BEGIN b := b * 2; a := a + 3; BEGIN ... END END ENDIF; 12. 想請問 (1) CASE expression OF 之後是否一定要換行? (2) WHILE boolean-expression DO 是否一定在同一行? Ans: (1) Yes. (2) Yes, 13.請問 WRITE中是否會有expression, 例如: WRITE(x+3) Ans:The syntax of WRITE is WRITE(non-empty-list-of-variables/constants) So expressions are not allowed. 14. 想再請問一下 boolean expression 中 IF a THEN ENDIF (a is integer/real) 或 IF 1 THEN ENDIF 這種是合法的嗎? Ans: Both are illegal. A boolean expression is comparisons between equivalent-typed arithmetic expressions plus using logical operators. 15. 請問 sub_proc 可以使用 super_proc 的 arguments 嗎? Example: PROCEDURE p(x:INTEGER); PROCEDURE pp(); BEGIN x := 10; # Can pp() use the argument x of p()? END BEGIN pp(); END Ans: This is legal. x is treated as a declared local variable in the scope of procedure p.