F# interactive can't guess when an expression is finished. It needs a special to token, that say "end of expression - you can evaluate this". This token is ";;" (that comes from OCaml world). Thus, if you run fsi.exe, you need this ";;". However, you usually don't want to type it, and F# editors usually silently insert this token.

This explains the strange error message. A message like "unexpected end of expression" would better (and "expecting 'then'" would be great).

Laurent.

By on 2/21/2009 1:56 PM ()

LLB: Just to be clear, I am typing this code into the code window and then sending it to F# Interactive -- this automatically inserts the ";;". If I type the expression directly in Interactive with the ";;" I still get the same error.

That is what makes this error so maddening. Even worse, there is no doubt that the parser/compiler "knows" (at some level) that it is looking for a "then" and hasn't found it so generating a helpful error should be straightforward.

My guess is that improving error messages is on the "to do" list for future releases. Good error messages are critical to spurring adoption -- the harder it is to write F# code, the fewer people will want to use it.

By on 2/22/2009 5:40 AM ()

You forgot the "then"

1
2
3
4
5
if true then printfn "hi";;


hi
val it : unit = ()
By on 2/21/2009 12:12 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