caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ivan Gotovchits <ivg@ieee.org>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: caml-list <caml-list@inria.fr>, Pierre Weis <Pierre.Weis@inria.fr>
Subject: Re: [Caml-list] Deprecation of tabulation boxes
Date: Mon, 19 Dec 2016 13:51:10 -0500	[thread overview]
Message-ID: <CALdWJ+y2Hhryx5G+ZpvTqQYEhUzmB4k8u806kh9HfLjL2PiD7g@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBEABzrmKKMT6FjwA0zvbFM19mKMZsbyCsZestNQ2sEajQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 5339 bytes --]

Well, the discussion literally says, we don't understand tabulation, and it
looks like nobody is using it, so let's just throw it away :)

We're using tabulation, and they are quite useful. Yep, I agree, that the
interface for setting the marks is kind of awkward,
it would be nice if there would be a `pp_setup_tabs : _ formatter -> int
list -> unit` function, that would push into the stack a new tabular box
with
the specified tabulations.

What concerning your solution with the alignment, it is less general and
doesn't work in our case. First of all, the pretty printing functions, that
are printing
into the columns are not specified with `%s`, but with `%a` (e.g., address,
memory string, assembly string). Second, the printing functions are not
actually
defined in the same module. The tabs are initialized in the frontend, that
defines it based on the architecture (address size, maximum length of
instruction, etc),
and pretty printers are registered separately, and they just rely on a
fact, that we have three columns, the first is for address, the second is
for memory, then assembly, etc).
This design simplifies the actual instruction printers, by consolidating
the common code in the formatter setup procedure.

So, it is still not clear to me, why the tabulations are wrong. If they do
complicate the code base and raise the support cost, then it is
understandable, why you would like to remove it
from the standard library. But in this case, it would be nice, to move this
code out as a separate library, as just removing a feature, that was in the
language for years (I would say even forever,
if we will start the history from caml-light), without providing any
substitution is... not nice :)


[1]: http://caml.inria.fr/pub/docs/manual-caml-light/node15.5.html



On Mon, Dec 19, 2016 at 1:20 PM, Gabriel Scherer <gabriel.scherer@gmail.com>
wrote:

> You may be interested in the discussion
>   https://github.com/ocaml/ocaml/pull/229
> which discussed a few ways in which the proposed tabulation interface
> may be inconvenient. It is after this discussion that Pierre Weis
> decided to deprecate tabulation boxes -- I believe that the reason is
> that tabulation and formatting never mixed very well.
>
> Note that if you can decide in advance a maximal size for a given
> "column" of your formatted output, you can use the left or
> right-justification features of formatting conversions to print
> aligned text:
>
> let data = [("x", "foo"); ("loop", "bar")]
>
> let () =
>   print_newline ();
>   data |> List.iter (fun (lab, instr) -> Printf.printf "%5s: %s\n" lab
> instr)
> (*
>     x: foo
>  loop: bar
> *)
>
> let () =
>   print_newline ();
>   data |> List.iter (fun (lab, instr) -> Printf.printf "%-5s: %s\n" lab
> instr)
> (*
> x    : foo
> loop : bar
> *)
>
> let () =
>   let len = List.fold_left (fun m (lab, _) -> max m (String.length
> lab)) 0 data in
>   print_newline ();
>   data |> List.iter (fun (lab, instr) -> Printf.printf "%*s: %s\n" len
> lab instr)
> (*
>    x: foo
> loop: bar
> *)
>
> On Mon, Dec 19, 2016 at 12:59 PM, Ivan Gotovchits <ivg@ieee.org> wrote:
> > Greetings,
> >
> > The tabulation boxes are marked as deprecated since 4.03.0. I've tried to
> > google for
> > any reasons that justify the removal but found only a note by Pierre
> Weis in
> > the Matis issue tracker[1]:
> >
> >
> >> The proposed printf-like syntax is fine, but tabulation boxes are now
> >> deprecated.
> >> Indeed, tabulation boxes interaction with other pretty-printing boxes
> have
> >> never been sorted out and tabulation boxes usage is orthogonal to the
> rest
> >> of the Format module.
> >> If considered useful, tabulation boxes could be implemented out of the
> >> Format module.
> >
> >
> > First of all the tabulation boxes can't be implemented outside of the
> format
> > module since the tab stops are actually stored in the stack of tabulation
> > boxes. If this data field would be removed from the formatter we will
> need
> > to pass an extra argument to all pretty-printers that use the tabulation
> > break, or use some global variable. Neither solution can be considered
> > acceptable.
> >
> > Speaking about the usefulness. The tabulation boxes are useful for
> printing
> > assembly outputs. And since compiler writing is sort of an application
> area
> > for OCaml, it shouldn't be considered as a rare case. It is also very
> useful
> > for printing Fortran code, that can be considered an assembler for the
> > numeric computing. It also just allows printing nicely formatted texts,
> that
> > it the main purpose of the Format library. As an example, tabulation
> boxes
> > are used in BAP and CIL frameworks.
> >
> > To summarize, the deprecation will eventually make few project
> > non-compilable. And there is no clear substitution for the deprecated
> > feature.
> >
> > Given that, I would like to hear the justifications for the deprecation
> of
> > tabulation boxes and suggested workarounds.
> >
> > One possible workaround, that I could see, is making the `formatter` type
> > extensible with existential boxes or, more generally, with existential
> > attributes. In that case, we will indeed be able to implement tabulation
> > boxes outside of the format module.
> >
> > Best wishes,
> > Ivan Gotovchits
> >
> > [1]: https://caml.inria.fr/mantis/view.php?id=4665
>

[-- Attachment #2: Type: text/html, Size: 6800 bytes --]

  reply	other threads:[~2016-12-19 18:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 17:59 Ivan Gotovchits
2016-12-19 18:20 ` Gabriel Scherer
2016-12-19 18:51   ` Ivan Gotovchits [this message]
2017-01-01 17:58     ` Pierre Weis
2017-01-03 15:33       ` Ivan Gotovchits

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=CALdWJ+y2Hhryx5G+ZpvTqQYEhUzmB4k8u806kh9HfLjL2PiD7g@mail.gmail.com \
    --to=ivg@ieee.org \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=gabriel.scherer@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;
as well as URLs for NNTP newsgroup(s).