List Info

Thread: Re: Re Learning camlp4




Re: Re Learning camlp4
country flaguser name
United Kingdom
2007-05-21 08:54:45


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&gt; declares nothing and
> can't be exported.
> let n = 1000
>; let () = <expr&gt;
> declares n as top-level value and makes some side-effect.
> Both n and <expr&gt; 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&gt;;
> I know I can refer to value x anywhere after its
> declaration. But when I see
> let x = <expr&gt;
> in original syntax, I should go many lines down the source
&gt; to see if there is " .. in .. " continuation, and some lines
&gt; up to see if it is a construction like
>; let top_level_value =
> let some_other_value =
> ...
> in
> let x = <expr&gt;
> in
> ...

You'll never have this problem if you indent your code.

Vincent

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )