Next: , Up: (dir)

Scripting Languages G22.3033-002 Summer 2008


Previous: Top, Up: Top

Scripting Languages G22.3033-002 Summer 2008 quiz1

Thursday 6/5/2008. 30 points.

http://www.cs.nyu.edu/courses/summer08/G22.3033-002/


Up: quiz1

Quiz 1 problems.


Next: , Up: quiz1-problems

quiz1-1 Gradual typing

(10 points) Add explicit type annotations to the following VBA module.

     Function geometricMean(arr())
       geometricMean = 1
       For i = LBound(arr) To UBound(arr)
         geometricMean = geometricMean * arr(i)
       Next i
       n = 1 + UBound(arr) - LBound(arr)
       geometricMean = geometricMean ^ (1.0 / n)
     End Function
     Sub main()
       Dim A(1)
       A(0) = 1: A(1) = 2
       Debug.Print geometricMean(A)
     End Sub


Next: , Previous: quiz1-1, Up: quiz1-problems

quiz1-2 Precedence and associativity

(10 points) Consider the following excerpt of Perl's operator table.

     Operator  Arity  Associativity  Description
     **        2      right          exponentiation
     *         2      left           multiplication
     =         2      right          assignment

Fully parenthesize the following expression: $x = $y = 3 ** 3 ** 3 * 2.


Previous: quiz1-2, Up: quiz1-problems

quiz1-3 Call-backs

(4+3+3 = 10 points)

  1. How are call-backs supported in VBA user forms?
  2. Give an advantage for this language design choice.
  3. Give a disadvantage for this language design choice.