* [Caml-list] ocp-indent begin/end behaviour?
@ 2016-09-15 19:01 Malcolm Matalka
2016-09-19 9:39 ` Goswin von Brederlow
2016-10-03 7:02 ` Louis Gesbert
0 siblings, 2 replies; 3+ messages in thread
From: Malcolm Matalka @ 2016-09-15 19:01 UTC (permalink / raw)
To: caml-list
I have the following code that I'm using ocp-indent to indent:
let () =
match Random.int 10 with
| 1 -> begin
zoom ();
baz ()
end
| 2 ->
()
The zoom and baz are indented "double", and I cannot figure out how to
undo that. I'd like the begin/end to have no effect on indentation at
all. Is this a bug or am I doing something wrong?
/Malcolm
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocp-indent begin/end behaviour?
2016-09-15 19:01 [Caml-list] ocp-indent begin/end behaviour? Malcolm Matalka
@ 2016-09-19 9:39 ` Goswin von Brederlow
2016-10-03 7:02 ` Louis Gesbert
1 sibling, 0 replies; 3+ messages in thread
From: Goswin von Brederlow @ 2016-09-19 9:39 UTC (permalink / raw)
To: caml-list
On Thu, Sep 15, 2016 at 07:01:00PM +0000, Malcolm Matalka wrote:
> I have the following code that I'm using ocp-indent to indent:
>
> let () =
> match Random.int 10 with
> | 1 -> begin
> zoom ();
> baz ()
> end
> | 2 ->
> ()
>
> The zoom and baz are indented "double", and I cannot figure out how to
> undo that. I'd like the begin/end to have no effect on indentation at
> all. Is this a bug or am I doing something wrong?
>
> /Malcolm
Double seems right since the match case indents and begin/end also
needs to indent since it creates a sub block. Consider this:
let () =
match Random.int 10 with
| 1 ->
bar ();
begin
zoom ();
baz ()
end;
foo ()
| 2 ->
()
Note: The only reason to use begin/end for a match case is if you have
another match inside I believe.
MfG
Goswin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] ocp-indent begin/end behaviour?
2016-09-15 19:01 [Caml-list] ocp-indent begin/end behaviour? Malcolm Matalka
2016-09-19 9:39 ` Goswin von Brederlow
@ 2016-10-03 7:02 ` Louis Gesbert
1 sibling, 0 replies; 3+ messages in thread
From: Louis Gesbert @ 2016-10-03 7:02 UTC (permalink / raw)
To: caml-list, Malcolm Matalka
On jeudi 15 septembre 2016 19:01:00 CEST Malcolm Matalka wrote:
> I have the following code that I'm using ocp-indent to indent:
>
> let () =
> match Random.int 10 with
>
> | 1 -> begin
>
> zoom ();
> baz ()
> end
>
> | 2 ->
>
> ()
>
> The zoom and baz are indented "double", and I cannot figure out how to
> undo that. I'd like the begin/end to have no effect on indentation at
> all. Is this a bug or am I doing something wrong?
>
> /Malcolm
ocp-indent is all about compromises and trying to keep programs visually
consistent. Also, it attempts to keep the configuration options to a minimum
so that their effects can still be easily understood, and styles don't diverge
too much.
In this case, `zoom (); baz ()` is inside two scopes that can be closed
individually (`->` and `begin/end`). So, as Goswin pointed out, without that
extra indentation the `end` would have to be either at the level of the `|` or
that of `zoom ();`, which isn't totally accurate, and in either case, if you
were to add `; some more stuff` after `end`, you couldn't get a proper
indentation without backtracking anymore.
So it's not a bug, but a design choice -- it's impossible to satisfy everyone
anyway (-- or it would end up like LaTeX). Note that it's designed to play
well with interactive use + partially manual indent (e.g. if you move `zoom
();`, `baz ()` will follow)
Best,
Louis Gesbert -- OCamlPro
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-03 7:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 19:01 [Caml-list] ocp-indent begin/end behaviour? Malcolm Matalka
2016-09-19 9:39 ` Goswin von Brederlow
2016-10-03 7:02 ` Louis Gesbert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox