F# – Should I learn with or without #light?

I’d definitely prefer learning F# with the #light syntax. The non-light version is sometimes useful for understanding some tricks about the F# syntax, but the #light syntax gives you much pleasant experience.

For example – using #light

let add a b c = 
  let ab = a + b
  printfn "%d" ab
  c - ab

Using non-light you can write the same thing like this:

let add a b c = 
  let ab = a + b in // 'in' keyword specifies where the binding (value 'ab') is valid
  printfn "%d" ab;  // ';' is operator for sequencing expressions
  c - ab;;          // ';;' is end of a function declaration

This for example shows that you cannot write something like:

let doNothing a b = 
  let sum = a + b in 

There is an ‘in’ keyword at the end but the function doesn’t have any body (because there is no expression following ‘in’). In this case non-light syntax is sometimes interesting to understand what’s going on… But as you can see, the #light code is a lot simpler.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)