On can use this to show that temp is only used in the definition of a1 :
let a1 = let temp = 42 in temp + 2 in let a2 = ...
The scope of temp really limited by the definition of a1 .
Another template uses the same name to hide its previous use, thus it is also clear that the previous use is temporary:
let result = input_string inchan in let result = parse result in let result = eval result in result
Reusing the same name is controversial.
Of course, there are always comments and blank lines:
let a1 = ... let a2 = ... let a3 = ... (*We now define f3:*) let f1 = ... let f2 = ... let f3 = ... f3 a1 a2 a3
Edit: as fmr pointed out, I am also fond of the pipe operator. It is not defined by default in OCaml, use
let (|>) xf = fx;;
Then you can write something like
input_string inchan |> parse |> eval |> print
jrouquie
source share