Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
108 Declarative Computation Model hard data exists to quantify these differences. In our experience, the differences are not great. Programming with static typing is like word processing with a spelling checker: a good writer can get along without it, but it can improve the quality of a text. Each approach has a role in practical application development. Static typ- ing is recommended when the programming techniques are well-understood and when efficiency and correctness are paramount. Dynamic typing is recommended for rapid development and when programs must be as flexible as possible, such as application prototypes, operating systems, and some artificial intelligence ap- plications. The choice between static or dynamic typing does not have to be all or noth- ing. In each approach, a bit of the other can be added, gaining some of its ad- vantages. For example, different kinds of polymorphism (where a variable might have values of several different types) add flexibility to statically-typed function- al and object-oriented languages. It is an active research area to design static type systems that capture as much as possible of the flexibility of dynamic type systems, while encouraging good programming style and still permitting compile time verification. The computation models given in this book are all subsets of the Oz lan- guage, which is dynamically typed. One research goal of the Oz project is to explore what programming techniques are possible in a computation model that integrates several programming paradigms. The only way to achieve this goal is with dynamic typing. When the programming techniques are known, then a possible next step is to design a static type system. While research in increasing the functionality and expressiveness of Oz is still ongoing in the Mozart Consortium, the Alice project at Saarland University in Saarbr¨ucken, Germany, has chosen to add a static type system. Alice is a statically-typed language that has much of the expressiveness of Oz. At the time of writing, Alice is interoperable with Oz (programs can be written partly in Alice and partly in Oz) since it is based on the Mozart implementation. 2.8 Exercises 1. Consider the following statement: proc {P X} if X>0 then {P X-1} end end Is the identifier occurrence of P in the procedure body free or bound? Justify your answer. Hint: this is easy to answer if you first translate to kernel syntax. Copyright c ± 2001-3 by P. Van Roy and S. Haridi. All rights reserved.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2.8 Exercises 109 2. Section 2.4 explains how a procedure call is executed. Consider the following procedure MulByN : declare MulByN N in N=3 proc {MulByN X ?Y} Y=N*X end together with the call {MulByN A B} . Assume that the environment at the call contains { A 10, B x 1 } . When the procedure body is executed, the mapping N 3 is added to the environment. Why is this a necessary step?
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 30


This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online