by panic · 9y ago · 0 comments
function f() { g() }
f()
var x = read_user_input()
function g() { print x }
Static languages typically don't allow the calls to f() and read_user_input() -- maybe that's the right answer here. There are other answers that come to mind as well. But, either way, I don't think we should perpetuate the mistake of dynamic variable lookup. let rec even n =
match n with
| 0 -> true
| x -> odd (x-1)
and odd n =
match n with
| 0 -> false
| x -> even (x-1)
Although personally I've never liked the idiom where everything at the top-level is a statement. Even in OCaml I usually define a 'main' function, and call it at the bottom of the file: let main args = do stuff...
...
let () = main Sys.argv> Although personally I've never liked the idiom where everything at the top-level is a statement.
For statically-typed languages, I'm not a huge fan of it either. But for dynamically-typed ones, I think it works out OK.