As Lee noted, F # does not allow you to specify a strategy for evaluating function arguments. This is certainly a useful function, but I think sometimes it can be confusing - for example, if you have a first-class function like int -> int , then the type does not tell you which evaluation strategy to use, so you either need to do types are more complex or restrict this for named functions.
In addition to working with lambda functions explicitly, F # also provides support for lazy evaluation (that is, evaluates lazily, but caches the result) using the lazy and Lazy<'T> keywords:
let foo (a:Lazy<int>) (b:Lazy<int>) = if a.Value = 0 then 0 else b.Value
This function will evaluate the second argument only if the first is nonzero:
foo (lazy (printfn "a"; 0)) (lazy (printfn "b"; 10)) // Prints just 'a' foo (lazy (printfn "a"; 10)) (lazy (printfn "b"; 10)) // Prints both 'a' and 'b'
This is a little more syntactically easy than using functions, but it still requires explicit specification on the client site, and not just on the declaration site.
source share