rec-with

3 views
Skip to first unread message

Nate Cerny

unread,
Apr 13, 2011, 3:18:48 PM4/13/11
to byu-cs-330-Winter-2011
In the assignment under generate constraints it says the following:

"The bound body of a rec binding does not have to be a syntactic
function. However, you may assume that the rec-bound identifier only
appears under a fun in the bound body. In other words, the following
expressions are legal:
(rec (f (fun (x) (f x)))
....)
(rec (f (with (y 4)
(fun (x) (f y))))
....)
while the following are not legal:
(rec (f f)
....)
(rec (f (+ 1 f))
....)"
Is this saying that we should check while generating constraints if
the bound-body of a rec contains an identifier equal to it's bound-id
and if they are equal and f is not a fun that we should throw an
error?

Does it also mean that while generating constraints if we find an
identifier in the bound-body that is equal to the bound-id that we
should throw an error?

Bryan Morse

unread,
Apr 13, 2011, 3:48:23 PM4/13/11
to byu-cs-330-...@googlegroups.com
The whole point of a recursive construct is so that you can use the bound-id in the bound-body, so that's definitely not an error. But it if should appear within a function body.

Here's what I wrote about this in an earlier message:

> 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