From: Louis Gesbert <louis.gesbert@ocamlpro.com>
To: caml-list@inria.fr, Malcolm Matalka <mmatalka@gmail.com>
Subject: Re: [Caml-list] ocp-indent begin/end behaviour?
Date: Mon, 03 Oct 2016 09:02:25 +0200 [thread overview]
Message-ID: <8387589.2ddTWeEJPz@maitake> (raw)
In-Reply-To: <86zin96l8z.fsf@gmail.com>
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
prev parent reply other threads:[~2016-10-03 7:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-15 19:01 Malcolm Matalka
2016-09-19 9:39 ` Goswin von Brederlow
2016-10-03 7:02 ` Louis Gesbert [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8387589.2ddTWeEJPz@maitake \
--to=louis.gesbert@ocamlpro.com \
--cc=caml-list@inria.fr \
--cc=mmatalka@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox