Section 4.3 Flashcards
True or false: Constant pattern matching in Miranda is strict.
True
True or false: Sum pattern matching in Miranda is strict.
True
True or false: Product pattern matching in Miranda is strict.
False
True or false: Lazy product matching is less efficient than strict product matching.
True. Applying lazy product matching can require more reductions than strict pattern matching.
Why do the semantic equations for pattern matching not include mismatched arguments (e.g a non-product argument applied to a lambda abstraction with a product pattern)?
The evaluation function is defined as an ordinary mathematical function, and such definitions are given only on the function’s domain.
Operationally, the type-checker ensures that functions are never applied to values outside of their domain.
What properties of a case expression make efficient implementation possible?
Exhaustiveness and the restriction to simple patterns.
Why is exhaustiveness required?
The patterns must be exhaustive so that the unconditional jump on the constructor always succeeds.
Why is the simple pattern restriction required?
If the one of the patterns is nested, one can no longer jump on the outermost constructor alone.