Scripting Languages CSCI-GA.3033.003, Summer 2012 quiz1

Thursday 6/7/2012. 30 points.

quiz1_1 Gradual typing

1a.
(4 points) Briefly define what “gradual typing” means.
1b.
(3 points) What is an advantage of dynamic typing over static typing?
1c.
(3 points) Is it possible to have implicit declarations with static typing?

quiz1_2 Precedence and associativity

2a.
(4 points) Assume that you are using a programming language where the operators + and * have the same precedence, and are both left-associative. What does the expression 1 + 2 * 3 + 1 evaluate to?
2b.
(4 points) Assume that you are using a programming language where the operator - is right-associative. What does the expression 4 - 3 - 2 - 1 evaluate to?
2c.
(4 points) Under what circumstances does associativity matter for the + operator?

quiz1_3 Properties

3a.
(4 points) Consider the following definition for a VBA class CircularBuffer:
Private Arr() As Integer
Sub Class_Initialize()
  Redim Arr(0 To 3)
End Sub
Property Let Buf(Idx As Integer, Val As Integer)
  Arr(Idx Mod 4) = Val
End Property
Property Get Buf(Idx As Integer) As Integer
  Buf = Arr(Idx Mod 4)
End Property
What does the following client code print?
Dim B as CircularBuffer
Set B = New CircularBuffer
B.Buf(0) = 10: B.Buf(1) = 11: B.Buf(2) = 12: B.Buf(3) = 13: B.Buf(4) = 14
Debug.Print B.Buf(0)
Debug.Print B.Buf(5)
3b.
(4 points) How are indexed properties used in the PowerPoint object model?

http://cs.nyu.edu/courses/summer12/CSCI-GA.3033-003/quiz1.html