what function enforces recursive rules?

4 views
Skip to first unread message

derrick white

unread,
Apr 8, 2011, 4:48:23 PM4/8/11
to byu-cs-330-Winter-2011
On the website for the type inferrer, there is found the following
notification:

the following are not legal:
(rec (f f)
....)
(rec (f (+ 1 f))
....)

however, I do not see a fundemental type error in (rec (f (+ 1
f)) ...). Yes, its a recursive mess, but the type inferrer should say
that f is a number because the addition is a number, and the addition
is a number because one and f and numbers.

Should Unify be catching the illegal use of f (I don't think so),
should parse be catching it, or should generate-constraints be
catching it. What kind of an error is this technically?

Bryan Morse

unread,
Apr 8, 2011, 5:04:25 PM4/8/11
to byu-cs-330-...@googlegroups.com
See Section 9.3 of your textbook for why this is a problem.

But this note is there more to let you know that you can assume valid input here (the recursively defined identifier showing up only inside the body of function definitions) rather than specifying something you should catch.

If you were to try to catch it, it's really more of a run-time problem since the "f" in the initialization expression refers to the same one being defined and is hence uninitialized.

Reply all
Reply to author
Forward
0 new messages