[bitc-dev] OCaml syntax question
Zorg 421
zorglub421 at gmail.com
Thu Mar 5 12:26:53 EST 2009
Oh, there's this unused "revised syntax" for ocaml:
http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html
also F# have a "do" keyword if I remember well.
regards.
On Thu, Mar 5, 2009 at 6:10 PM, Geoffrey Irving <irving at naml.us> wrote:
> On Thu, Mar 5, 2009 at 8:52 AM, Jonathan S. Shapiro <shap at eros-os.com> wrote:
>> This is the obverse problem, but there is a visual clue here: two
>> statements not surrounded by curly braces should never be indented at
>> the same level.
>>
>> And clearly we could run emacs and get the OCaml let bindings indented
>> correctly. The right question: why is the OCaml community apparently
>> failing to do so ten years later?
>
> I think I can answer this question, as someone who will admit to have
> their mind rotted by ocaml syntax (given the previous email). :)
>
> The basic reason is that because ever variable binding in ocaml
> introduces a new indentation level, a program that added extra spaces
> every time you add a scope would quickly develop an absurd level of
> indentation. In other words, it would be like writing C code like
> this:
>
> int x = 1;
> int y = 3;
> int z = 5;
>
> Yes, you can do this with "and", but that is annoying in the sense
> that if you write
>
> let x = 1
> and y = 2 in
> ...
>
> you can't just delete the "int x = 1" line and get a valid program.
> The result of this is that people end up using indentation to reflect
> how _they_ think about the structure of a program, not how the
> compiler is parsing it. E.g., I consider the following to be
> *correctly* indented:
>
> let f z =
> let x = 1 in
> let y = 2 in
> g x y z
>
> Note: I'm aware you might strongly disagree, and am just trying to
> explain how at least one ex-ocaml programmer thinks about ocaml
> syntax.
>
> Geoffrey
> _______________________________________________
> bitc-dev mailing list
> bitc-dev at coyotos.org
> http://www.coyotos.org/mailman/listinfo/bitc-dev
>
More information about the bitc-dev
mailing list