COSC3308 TEST-2					11/16/2000

	NAME________________________________________
		
	PART-A.	True/False questions.			(48 points)
	Choose 16 questions in this PART-A.	
	All 20 questions are on SNOBOL4.

	1. 	ABC = "NICE"
		NICE = "GOOD"
		OUTPUT  =  $ABC

	   The string "GOOD" will be output

	2.	OUTPUT=STRING
		OUTPUT  =  STRING
	   The above two statements are equivalent.

	3.	STRING  PATT
		STRING  PATT  =
	   The above two statements are equivalent.

	4.	&fullscan  =  1
		Pat  = 'a'  |  *Pat 'b'
		'abbb'  Pat  $  Output  Fail

	   The output will be:
		a
		ab
		abb
		abbb
	        followed by an error message because the recursive cycle
	        is not broken.

	5.	&Fullscan = 0
		Pat  =  *Pat  'a'  |  'b'
		'baaa'  Pat  $  Output  Fail

	   The output will be:
		b
		ba
		baa
		baaa

	6.	&anchor  =  0
		string  =  'lamaruniversity'
		string span('amru')  .  output

	   The output will be the string "amaru"

	7.	&anchor  =  1
		string  =  'lamaruniversity'
		string  span('amru')  .  Output

	   The output will be the null-string.

	8.	&Anchor = 1
		"(A+B)*C"  Bal  $  Output  Fail

	   The only outputs will be:
		(A+B)
		(A+B)*
		(A+B)*C

	9. The primitive pattern function "BREAK" can match the Null-string.
           But, the primitive pattern function "SPAN" cannot match the
	   Null-string.

	10. 	String RTAB(0)
		String REM
	    The above are euivalent.

	11.	String POS(0)  Pat  RPOS(0)
	    The above pattern matching succeeds only if the given pattern
	    matches the entire subject string.

	12. 	String   Pat1  |  Pat2   Pat3
		String   ( Pat1 | Pat2 ) Pat3
	    The above are equivalent.

	13. In order to pass a parameter by address, we can use a string
	    instead of a variable name.
	
	14. "FRETURN" is to have a function return in failure.
	    In this case, the value of the returning function is
	    the Null-string.

	15. In quickscan, every unevaluated expression used in a pattern 
	    structure is assumed to match at least one character.

	16.	differ(X,Y)		:s(good)
		differ(Y,Z)		:s(good)
	    The above two lines are equivalent to:
		differ(X,Y)  differ(Y,Z)   :s(good)

	17. The primitive pattern function "ARB" matches any substring 
	    of the subject string except the Null-string.

	FOR QUESTIONS 18, 19, AND 20, REFER TO THE FOLLOWING PROGRAM:

		
		define('f1()loc1')
		define('f2()loc2')
	main	loc1  =  3333
		loc2  =  1111
		loc3  =  9999   
		Output = loc1  loc2  loc3
		f1()
		Output = loc1  loc2  loc3	:(end)
	f1	output = loc1  loc2  loc3
		loc1  =  5555    
		f2()
		output = loc1  loc2  loc3       :(return)
	f2	loc2  =  2222
		output = loc1  loc2  loc3
		f2  =  loc1			:(return)
	end
	*** END OF PROGRAM
	*****************************************************

	18. The two output statements of the Main program give
	    the same output.

	19. The first output statement of 'f1' will output only two numbers.

	20. The value of the function f2 will be 5555 and not 3333.
	
	*************END-OF-SNOBOL4-QUESTIONS****************


	PART-B. Multiple Choices Questions.		(24 points)
	Answer all questions in this PART by selecting the BEST
	one answer.

	21. In parameter passing, an aliasing can occur in
		a. By-value passing
		b. By-reference passing
		c. Both.		d. Neither
	22. By-name passing has the same effect as By-reference
	    passing when the actual parameter is
		a. a constant like 16
		b. a scalar variable like ABC
		c. an array element like ABC[k]
		d. Two above.		e. None
	23. When the actual parameter is an entire array name, which is
	    most efficient?
		a. By-value passing.
		b. By-reference passing.
		c. By-name passing
		d. Cannot tell.
	24. Static variables are for 
		a. the Deletion implementation.
		b. the Retention implementation
		c. Cannot tell or either.
	25. The Referencing Environment can be implemented by
		a. runtime central stack
		b. a central name table
		c. Both.		d. Neither.
	26. As a referencing environment, the Central Name Table is
	    more preferable when
		a. frequent subprogram calls are expected.
		b. subprograms have many local variables.
		c. Both.		d. Neither.


	PART-C. Other Problems.				(28 points)
	Choose three problems in this PART-B.

	A. Compare SNOBOL Quickscan and Fullscan. 

	B. Consider the following function definition:

		define('three(a,b,c)')

	   This function finds and prints all combinations of
	   three numbers out of 6 numbers: 1,2,3,4,5,6.

	   Complete this function definition.
	   Note that the first statement must have the appropriate label.
	   Also, assume that you have the following function already
	   available:  	define('threeoutput(x,y,z)')
		 threeoutput   output = x ' ' y ' ' z   :s(return)

	C. Discuss briefly some design issues of subprograms.

	D. What is the referencing environment?
	   Briefly describe ways of implementing it.

	E. What are some advantages and disadvantages of By-Name
	   parameter passing?