comp.lang.ada
 help / color / mirror / Atom feed
* gnatpp parameter alignment
@ 2018-11-28  0:34 julian.fondren
  2018-11-28  7:37 ` briot.emmanuel
  2018-11-28  9:02 ` Simon Wright
  0 siblings, 2 replies; 7+ messages in thread
From: julian.fondren @ 2018-11-28  0:34 UTC (permalink / raw)


Hello comp.lang.ada,

I thought I'd always use gnatpp for styling, but I've found this
formatting result that I don't like at all, and which seems to come up
a lot in my code (so often that !pp formatting escapes would be a
pain):

   function waitpid (Pid : Integer; Wstatus : System.Address;
      Options            : Integer) return Integer;

What I'd prefer is that, if parameters take up more than one line,
that they just switch to an entirely vertical formatting, something
like:

   function waitpid (Pid     : Integer;
                     Wstatus : System.Address;
                     Options : Integer) return Integer;

or

  function waitpid
    ( Pid     : Integer;
      Wstatus : System.Address;
      Options : Integer) return Integer;

Many other variations would be acceptable, as long as there aren't
multiple parameters on a line and *also* parameters across multiple
lines, especially with that long-distance horizontal alignment that
makes "Options" look like it's unrelated to the function definition
around it.

I've looked through gnatpp's flags and didn't find anything for
this. I like horizontal alignment in general, and I can deal with most
of the rest of gnatpp's results, so I don't want to turn off huge
swaths of gnatpp formatting. I just want this one case to not visually
suggest that a three-argument function has only two arguments.

Thanks.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  0:34 gnatpp parameter alignment julian.fondren
@ 2018-11-28  7:37 ` briot.emmanuel
  2018-11-28  7:56   ` Mark Lorenzen
  2018-11-28  8:42   ` Simon Wright
  2018-11-28  9:02 ` Simon Wright
  1 sibling, 2 replies; 7+ messages in thread
From: briot.emmanuel @ 2018-11-28  7:37 UTC (permalink / raw)


AdaCore has rewritten gnatpp, in the past few months, using libadalang instead of ASIS.
Perhaps they have also improved support for such constructs.

Doesn't seem to be available on github though (historically, gnatpp was in the
same RCS, then CVS then subversion repository as the compiler itself).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  7:37 ` briot.emmanuel
@ 2018-11-28  7:56   ` Mark Lorenzen
  2018-11-28  8:42   ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Mark Lorenzen @ 2018-11-28  7:56 UTC (permalink / raw)


On Wednesday, November 28, 2018 at 8:37:03 AM UTC+1, briot.e...@gmail.com wrote:
> AdaCore has rewritten gnatpp, in the past few months, using libadalang instead of ASIS.
> Perhaps they have also improved support for such constructs.
> 
> Doesn't seem to be available on github though (historically, gnatpp was in the
> same RCS, then CVS then subversion repository as the compiler itself).

I think it's available as part of the Libadalng-tools repository:

https://github.com/AdaCore/libadalang-tools

Regards,

Mark L


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  7:37 ` briot.emmanuel
  2018-11-28  7:56   ` Mark Lorenzen
@ 2018-11-28  8:42   ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2018-11-28  8:42 UTC (permalink / raw)


briot.emmanuel@gmail.com writes:

> AdaCore has rewritten gnatpp, in the past few months, using libadalang
> instead of ASIS.
> Perhaps they have also improved support for such constructs.
>
> Doesn't seem to be available on github though (historically, gnatpp
> was in the same RCS, then CVS then subversion repository as the
> compiler itself).

Because the CE version of ASIS contains CE/Pro specifics that won't let
it build under FSF GCC (mainly to do with identifying the compiler
version), I've posted a repo[1] at Github with the changes incorporated.

gnatpp is part of ASIS, and has been for as long as I've been working
with the FSF compiler.

[1] https://github.com/simonjwright/ASIS

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  0:34 gnatpp parameter alignment julian.fondren
  2018-11-28  7:37 ` briot.emmanuel
@ 2018-11-28  9:02 ` Simon Wright
  2018-11-28 13:50   ` Simon Wright
  2018-11-28 14:19   ` julian.fondren
  1 sibling, 2 replies; 7+ messages in thread
From: Simon Wright @ 2018-11-28  9:02 UTC (permalink / raw)


julian.fondren@gmail.com writes:

> I thought I'd always use gnatpp for styling, but I've found this
> formatting result that I don't like at all, and which seems to come up
> a lot in my code (so often that !pp formatting escapes would be a
> pain):
>
>    function waitpid (Pid : Integer; Wstatus : System.Address;
>       Options            : Integer) return Integer;

I suspect you're using GNAT CE 2018.

I've tried this with FSF GCC 4.8..9 and GNAT GPL 2015..2017 and all give
the result you prefer. Only CE 2018 shows this bad result.

The executables (macOS) are all ~10 MB except for CE 2018, which is 30
MB.

Following Emmanuel's remarks, I wonder whether what's happened is that
the CE 2018 gnatpp is in fact using the libadalang version? Bearing in
mind that the working GCC 9 version is built with ASIS CE 2018!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  9:02 ` Simon Wright
@ 2018-11-28 13:50   ` Simon Wright
  2018-11-28 14:19   ` julian.fondren
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Wright @ 2018-11-28 13:50 UTC (permalink / raw)


Just built the latest libadalang-tools version, which does not show this
behaviour.

With the input function & parameters on one line,

No switches:

$ bin/gnatpp -pipe ~/tmp/cla/waitpid.ads
with System;
function waitpid
  (Pid : Integer; Wstatus : System.Address; Options : Integer) return Integer;

Limit line length (default is 79):

s simon$ bin/gnatpp -pipe --max-line-length=75 ~/tmp/cla/waitpid.ads
with System;
function waitpid
  (Pid : Integer; Wstatus : System.Address; Options : Integer)
   return Integer;

If >=3 parameters, place each on separate line:

$ bin/gnatpp -pipe --par-threshold=3 ~/tmp/cla/waitpid.ads
with System;
function waitpid
  (Pid     : Integer;
   Wstatus : System.Address;
   Options : Integer)
  return Integer;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gnatpp parameter alignment
  2018-11-28  9:02 ` Simon Wright
  2018-11-28 13:50   ` Simon Wright
@ 2018-11-28 14:19   ` julian.fondren
  1 sibling, 0 replies; 7+ messages in thread
From: julian.fondren @ 2018-11-28 14:19 UTC (permalink / raw)


On Wednesday, November 28, 2018 at 3:02:35 AM UTC-6, Simon Wright wrote:
> julian.fondren@gmail.com writes:
> 
> > I thought I'd always use gnatpp for styling, but I've found this
> > formatting result that I don't like at all, and which seems to come up
> > a lot in my code (so often that !pp formatting escapes would be a
> > pain):
> >
> >    function waitpid (Pid : Integer; Wstatus : System.Address;
> >       Options            : Integer) return Integer;
> 
> I suspect you're using GNAT CE 2018.
> 
> I've tried this with FSF GCC 4.8..9 and GNAT GPL 2015..2017 and all give
> the result you prefer. Only CE 2018 shows this bad result.
> 

Ah, this is true. This result is from the latest binaries at
https://www.adacore.com/download

   GNATPP Community 2018 (20180523)
   Copyright (C) 2004-2018, AdaCore.
   This is free software; see the source for copying conditions.
   There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

On the Fedora box I'm using those as well because Fedora's packages
excluded gnatpp -- I've no idea why, but 'dnf whatprovides */gnatpp'
returns nothing and none of these packages provided it:

   fedora-gnat-project-common
   libgnat-devel
   libgnat-static
   libgnat
   gcc-gnat

For now I can just use whatever --par-threshold= keeps this formatting
away for a code base, and then revert to defaults when a newer build's
available.

Thanks again!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-11-28 14:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28  0:34 gnatpp parameter alignment julian.fondren
2018-11-28  7:37 ` briot.emmanuel
2018-11-28  7:56   ` Mark Lorenzen
2018-11-28  8:42   ` Simon Wright
2018-11-28  9:02 ` Simon Wright
2018-11-28 13:50   ` Simon Wright
2018-11-28 14:19   ` julian.fondren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox