CSE 305 Programming Languages Fall, 2003 Professor Shapiro Homework 3 Maximum Points: 12 Due 12:01 am, Thursday, September 25, 2003 Copy this file to a text file named hw3.txt, edit into it your answers, and submit the file via the submit program by the deadline given above. 1. (3) Using the "Higher-level, low-level language" for operational semantics, give the operational semantics of Java's do statement, do statement while (expression); 2. (3) Using the "Lower-level, low-level language" for operational semantics, give the operational semantics of the Java statement, x = y + z * w; 3. (3) Using the "Lower-level, low-level language" for operational semantics, give the operational semantics of the Java statement, j = i++ + i; 4. (3) As the text says, "Perl's dynamic scoping is unusual---in fact it is not exactly like that discussed in this section, although the semantics are often that of traditional dynamic scoping" [p. 218]. What is printed by the following Perl program: #! /util/bin/perl $x = 1; $y = 2; sub inner { # Print the nonlocals $x and $y print "x = $x, y = $y\n"; } sub outer { # The formal parameter is implicitly the array @_ # so the first argument is assigned to @_[0] # and the second argument is assigned to @_[1] # make $x have static scope my $x = @_[0]; # make $y have dynamic scope local $y = @_[1]; # Now call the subroutine inner inner; } # Call the subroutine outer with arguments 3 and 4 outer(3, 4);