Hi,

Mutually recursive values are forbidden, because it doesn't really make sens (which one is evaluated first?). A value and a function can be mutually recursive: this is somewhat dangerous, but it's sometimes useful (especially with laziness). I gave an example in a blog post: [link:laurent.le-brun.eu]

In your second example, the evaluation of y calls "f 1". "f 1" is 1 + x + y. x is 1, y is not yet initialized (I told you it's dangerous). For some reason, its value is 0 (this is the same as Unchecked.defaultof<int>).

When I read your message, I expected this result. However I thought you'd get a warning; it looks like a bug in F#, you should probably send a bug report about it.

Laurent

By on 4/2/2009 12:57 PM ()

The blog post contains a neat example of recursive values, thanks.

By on 4/2/2009 1:27 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper