Q3 Example Exam, Feb 24 2011

5 views
Skip to first unread message

Hugo

unread,
Mar 15, 2011, 7:14:17 AM3/15/11
to proglang-course-2011
Q3 for which the answer is

infer env (exp1 + exp2) =
typ := infer env exp1
check condition (typ == int || typ == double)
check env (exp2 : typ)
return typ


Are we here assuming an implicit Err-monad where each statement's
failure is taken care of? I mean, what if the type of exp1 cant be
inferred? Or else, what if the type of exp1 is neither int nor double?

The question says "the rule has to return a type". Maybe they meant it
should return a type as long as it doesnt return an error?

Arnar Birgisson

unread,
Mar 15, 2011, 7:52:50 AM3/15/11
to proglang-c...@googlegroups.com, Hugo
Hi,

Yes, in the answer implicit error handling is assumed. I.e. if either
of the check commands fail, the whole rule fails.

cheers,
Arnar

Reply all
Reply to author
Forward
0 new messages