[plt-scheme] The perfect teaching language--Is this too much to ask for?
Not a bug.
On Jun 15, 2009, at 10:17 AM, Stephen Bloch wrote:
> I'm trying out some of the contract features to see what I could
> reasonably use in a first programming course.
>
> (require scheme/contract)
>
> (define/contract (fact n)
> (-> number? number?)
> (cond [(= n 7) true]
> [(<= n 0) 1]
> [else (* n (fact (- n 1)))]))
>
> (check-expect (fact 0) 1)
> (check-expect (fact 1) 1)
> (check-expect (fact 4) 24)
> (check-expect (fact 7) "bad news")
> (check-expect (fact 8) "bad news")
>
> It correctly catches the contract violation on (fact 7) when it's
> called from check-expect, but if I comment out that test case and
> try (fact 8), it does NOT catch the contract violation when fact
> calls itself. I guess that's what "the definition is a contract
> boundary" means, and I see the argument for it on efficiency
> grounds, but it's sort of annoying for beginning-programming use.
>
>
> BTW, the above definition works in ISL, but doesn't pass a syntax
> check in BSL. I've bug-reported it.
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme