Le 21 mai 07 à 15:19, dmitry grebeniuk a écrit :
> Shalom, Jon.
>
>>> In revised syntax if I write "value x = 23;" I sure that
>>> I can never add " in ..." at the end and this binding won't
>>> be hidden by construction like
>>> "let x = 23 in x + 7".
>
> JH> This is a bad idea, IMHO. OCaml has no notion of
> JH> "global" scope, just a progression from outer to levels
> JH> of nested scope.
>
> It has global scope. Every value that should be visible
> to other modules should be declared in "global" scope (in
> "top level").
> let () = let n = 1000 in <expr> declares nothing and
> can't be exported.
> let n = 1000
> let () = <expr>
> declares n as top-level value and makes some side-effect.
> Both n and <expr> will be evaluated.
> So keyword "value" is here especially to note what will be
> evaluated at program's run and what can be exported from
> this module
I think this is the role of interfaces. Indeed, you may declare a
"value" that won't be exported because the interface said not
to do this.
> And one more thing: when I see
> value x = <expr>;
> I know I can refer to value x anywhere after its
> declaration. But when I see
> let x = <expr>
> in original syntax, I should go many lines down the source
> to see if there is " .. in .. " continuation, and some lines
> up to see if it is a construction like
> let top_level_value =
> let some_other_value =
> ...
> in
> let x = <expr>
> in
> ...
You'll never have this problem if you indent your code.
Vincent
.