Skip Menu |

This queue is for tickets about the Perl-Tidy CPAN distribution.

Report information
The Basics
Id: 125497
Status: open
Priority: 0/
Queue: Perl-Tidy

People
Owner: Nobody in particular
Requestors: rkleemann [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Support aligning numbers correctly
Date: Tue, 5 Jun 2018 13:39:54 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Bob Kleemann <rkleemann [...] gmail.com>
It would be nice if numbers were aligned in a sensible way, on the decimal point. Currently, all numbers are left-aligned, which makes sense in the simple case, but it would be nice if the following code aligned properly: my $price = 102.99; my $adjustment = -2.99; my $tax = 1.0775; my $final = ( $price + $adjustment ) * $tax; Of course, there is some question about how to align some of the more elaborate number formats: my $avagadro = 6.022140857E23; my $YYYYddd = 2018.156; my $pi = 3.14159265; my $green = 0x00ff00; my $rwxrw_rw_ = 0766; my $escape = 0b00011011; I think I've aligned them in a way that makes sense here, but I could see arguments for other alignments. Bob
Subject: Re: [rt.cpan.org #125497] Support aligning numbers correctly
Date: Wed, 6 Jun 2018 06:57:22 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Steven Hancock <s7078hancock [...] gmail.com>
Bob, Thanks for the suggestion. This could also be useful for large tables of values. I did look into it at one time but found that there were so many possible variations that it was hard to code. Steve On Tue, Jun 5, 2018 at 1:40 PM, Bob Kleemann via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Tue Jun 05 16:40:42 2018: Request 125497 was acted upon. > Transaction: Ticket created by rkleemann@gmail.com > Queue: Perl-Tidy > Subject: Support aligning numbers correctly > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: rkleemann@gmail.com > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > It would be nice if numbers were aligned in a sensible way, on the decimal > point. Currently, all numbers are left-aligned, which makes sense in the > simple case, but it would be nice if the following code aligned properly: > > my $price = 102.99; > my $adjustment = -2.99; > my $tax = 1.0775; > my $final = ( $price + $adjustment ) * $tax; > > > Of course, there is some question about how to align some of the more > elaborate number formats: > > my $avagadro = 6.022140857E23; > my $YYYYddd = 2018.156; > my $pi = 3.14159265; > > my $green = 0x00ff00; > my $rwxrw_rw_ = 0766; > my $escape = 0b00011011; > > > I think I've aligned them in a way that makes sense here, but I could see > arguments for other alignments. > > Bob > >
Subject: Re: [rt.cpan.org #125497] Support aligning numbers correctly
Date: Wed, 6 Jun 2018 10:02:42 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Bob Kleemann <rkleemann [...] gmail.com>
How many variations are there? Integers (a series of numbers that does not start with 0), decimal (a series of numbers followed by period, followed by another series of numbers), floating point (a decimal, followed by an 'e', followed by an integer), binary/octal/hex, and I think that's it. All of the values should be aligned on the single units or the period, except the binary/octal/hex, which should be aligned on the leading 0 (in my opinion, I can see discussion on that point). On Wed, Jun 6, 2018 at 6:58 AM Steven Hancock via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > Bob, > Thanks for the suggestion. This could also be useful for large tables of > values. > I did look into it at one time but found that there were so many > possible variations that it was hard to code. > Steve > > On Tue, Jun 5, 2018 at 1:40 PM, Bob Kleemann via RT < > bug-Perl-Tidy@rt.cpan.org> wrote: >
> > Tue Jun 05 16:40:42 2018: Request 125497 was acted upon. > > Transaction: Ticket created by rkleemann@gmail.com > > Queue: Perl-Tidy > > Subject: Support aligning numbers correctly > > Broken in: (no value) > > Severity: (no value) > > Owner: Nobody > > Requestors: rkleemann@gmail.com > > Status: new > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > > > It would be nice if numbers were aligned in a sensible way, on the
> decimal
> > point. Currently, all numbers are left-aligned, which makes sense in the > > simple case, but it would be nice if the following code aligned properly: > > > > my $price = 102.99; > > my $adjustment = -2.99; > > my $tax = 1.0775; > > my $final = ( $price + $adjustment ) * $tax; > > > > > > Of course, there is some question about how to align some of the more > > elaborate number formats: > > > > my $avagadro = 6.022140857E23; > > my $YYYYddd = 2018.156; > > my $pi = 3.14159265; > > > > my $green = 0x00ff00; > > my $rwxrw_rw_ = 0766; > > my $escape = 0b00011011; > > > > > > I think I've aligned them in a way that makes sense here, but I could see > > arguments for other alignments. > > > > Bob > > > >
> >
Subject: Re: [rt.cpan.org #125497] Support aligning numbers correctly
Date: Thu, 7 Jun 2018 07:24:39 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Steven Hancock <s7078hancock [...] gmail.com>
Here are some examples of issues that can arise (note: I'm not sure if my original spacing will survive email!) 1. Integers can be a big problem. They may or may not look okay when formatted this way. Consider: my $low = 1; my $delta = 2; my $hi = 101.1; This isn't too bad but it isn't so great either. Consider: my $i = 0; my $conversion_factor = 37458978.21; This doesn't look good at all. 2. It is very common to have additional operations in lists of numbers, and these may pose a problem. Consider my $conversion_factor = 37458978.21; my $conversion_factor2 = 167.22 * 2; This might be okay. But consider my $conversion_factor = 37458978.21; my $pi2 = 3.14159 * 2; my $pi4 = 4 * 3.14159; my $tol = 0.00000025; This is getting hard to read. 3. Adding the extra spaces to align numbers this way in lists may cause an entire list to be expanded in a very undesirable way. On Wed, Jun 6, 2018 at 10:04 AM, Bob Kleemann via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> Queue: Perl-Tidy > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > How many variations are there? Integers (a series of numbers that does not > start with 0), decimal (a series of numbers followed by period, followed by > another series of numbers), floating point (a decimal, followed by an 'e', > followed by an integer), binary/octal/hex, and I think that's it. All of > the values should be aligned on the single units or the period, except the > binary/octal/hex, which should be aligned on the leading 0 (in my opinion, > I can see discussion on that point). > > On Wed, Jun 6, 2018 at 6:58 AM Steven Hancock via RT < > bug-Perl-Tidy@rt.cpan.org> wrote: >
> > <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > Bob, > > Thanks for the suggestion. This could also be useful for large tables of > > values. > > I did look into it at one time but found that there were so many > > possible variations that it was hard to code. > > Steve > > > > On Tue, Jun 5, 2018 at 1:40 PM, Bob Kleemann via RT < > > bug-Perl-Tidy@rt.cpan.org> wrote: > >
> > > Tue Jun 05 16:40:42 2018: Request 125497 was acted upon. > > > Transaction: Ticket created by rkleemann@gmail.com > > > Queue: Perl-Tidy > > > Subject: Support aligning numbers correctly > > > Broken in: (no value) > > > Severity: (no value) > > > Owner: Nobody > > > Requestors: rkleemann@gmail.com > > > Status: new > > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > > > > > > It would be nice if numbers were aligned in a sensible way, on the
> > decimal
> > > point. Currently, all numbers are left-aligned, which makes sense in
> the
> > > simple case, but it would be nice if the following code aligned
> properly:
> > > > > > my $price = 102.99; > > > my $adjustment = -2.99; > > > my $tax = 1.0775; > > > my $final = ( $price + $adjustment ) * $tax; > > > > > > > > > Of course, there is some question about how to align some of the more > > > elaborate number formats: > > > > > > my $avagadro = 6.022140857E23; > > > my $YYYYddd = 2018.156; > > > my $pi = 3.14159265; > > > > > > my $green = 0x00ff00; > > > my $rwxrw_rw_ = 0766; > > > my $escape = 0b00011011; > > > > > > > > > I think I've aligned them in a way that makes sense here, but I could
> see
> > > arguments for other alignments. > > > > > > Bob > > > > > >
> > > >
> >
Subject: Re: [rt.cpan.org #125497] Support aligning numbers correctly
Date: Thu, 7 Jun 2018 09:31:03 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Bob Kleemann <rkleemann [...] gmail.com>
Your original spacing/formatting did not come through, so I reformatted it myself, as I'm guessing that you would have intended. I've also interspersed my comments. Here are some examples of issues that can arise (note: I'm not sure if my original spacing will survive email!) 1. Integers can be a big problem. They may or may not look okay when formatted this way. Consider: my $low = 1; my $delta = 2; my $hi = 101.1; This isn't too bad but it isn't so great either. In this case, as a programmer, I would put an empty line between $delta and $hi, which would then fix the "isn't so great" issue. Consider: my $i = 0; my $conversion_factor = 37458978.21; This doesn't look good at all. This is clearly a case where a blank line between $i and $conversion_factor would make things much more readable. 2. It is very common to have additional operations in lists of numbers, and these may pose a problem. Consider my $conversion_factor = 37458978.21; my $conversion_factor2 = 167.22 * 2; This might be okay. But consider my $conversion_factor = 37458978.21; my $pi2 = 3.14159 * 2; my $pi4 = 4 * 3.14159; my $tol = 0.00000025; This is getting hard to read. This is two separate issues. The $pi2 and $pi4 lines should be structured the same (float times integer or integer times float, but not both), so this is a problem with the programmer. Additionally, those two lines should be separated from the two lines declaring the constants $conversion_factor and $tol. If a programmer were to reformat it the way I'm suggesting, then the alignment is acceptable: my $conversion_factor = 37_458_978.21; my $tol = 0.00_000_025; my $pi2 = 2 * 3.14159; my $pi4 = 4 * 3.14159; 3. Adding the extra spaces to align numbers this way in lists may cause an entire list to be expanded in a very undesirable way. I'm totally agreeing that this might be an issue, which is why you have the #<<< and #>>> anchors. You might also consider a special case of those tags: #<<<no-align-numbers my @perfect_numbers = ( 6, 28, 496, 8_128, 33_550_336, 8_589_869_056, 137_438_691_328, 2_305_843_008_139_952_128, 2_658_455_991_569_831_744_654_692_615_953_842_176 ); #>>> Which would reformat that code: #<<<no-align-numbers my @perfect_numbers = ( 6, 28, 496, 8_128, 33_550_336, 8_589_869_056, 137_438_691_328, 2_305_843_008_139_952_128, 2_658_455_991_569_831_744_654_692_615_953_842_176 ); #>>> Which is less readable, but gets my point across. So, to summarize, a lot of your issues seem like they could be solved with some blank lines, or perhaps a way of turning off the alignment for a particular block of code. Bob On Thu, Jun 7, 2018 at 7:25 AM Steven Hancock via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > Here are some examples of issues that can arise (note: I'm not sure if my > original spacing will survive email!) > > > 1. Integers can be a big problem. They may or may not look okay when > formatted this way. Consider: > > > my $low = 1; > > my $delta = 2; > > my $hi = 101.1; > > > This isn't too bad but it isn't so great either. > > > Consider: > > > my $i = 0; > > my $conversion_factor = 37458978.21; > > > This doesn't look good at all. > > > 2. It is very common to have additional operations in lists of numbers, > > and these may pose a problem. Consider > > > my $conversion_factor = 37458978.21; > > my $conversion_factor2 = 167.22 * 2; > > > This might be okay. But consider > > > my $conversion_factor = 37458978.21; > > my $pi2 = 3.14159 * 2; > > my $pi4 = 4 * 3.14159; > > my $tol = 0.00000025; > > > This is getting hard to read. > > > > 3. Adding the extra spaces to align numbers this way in lists may cause an > > entire list to be expanded in a very undesirable way. > > > > > On Wed, Jun 6, 2018 at 10:04 AM, Bob Kleemann via RT < > bug-Perl-Tidy@rt.cpan.org> wrote: >
> > Queue: Perl-Tidy > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > How many variations are there? Integers (a series of numbers that does
> not
> > start with 0), decimal (a series of numbers followed by period, followed
> by
> > another series of numbers), floating point (a decimal, followed by an
> 'e',
> > followed by an integer), binary/octal/hex, and I think that's it. All of > > the values should be aligned on the single units or the period, except
> the
> > binary/octal/hex, which should be aligned on the leading 0 (in my
> opinion,
> > I can see discussion on that point). > > > > On Wed, Jun 6, 2018 at 6:58 AM Steven Hancock via RT < > > bug-Perl-Tidy@rt.cpan.org> wrote: > >
> > > <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > > > Bob, > > > Thanks for the suggestion. This could also be useful for large tables
> of
> > > values. > > > I did look into it at one time but found that there were so many > > > possible variations that it was hard to code. > > > Steve > > > > > > On Tue, Jun 5, 2018 at 1:40 PM, Bob Kleemann via RT < > > > bug-Perl-Tidy@rt.cpan.org> wrote: > > >
> > > > Tue Jun 05 16:40:42 2018: Request 125497 was acted upon. > > > > Transaction: Ticket created by rkleemann@gmail.com > > > > Queue: Perl-Tidy > > > > Subject: Support aligning numbers correctly > > > > Broken in: (no value) > > > > Severity: (no value) > > > > Owner: Nobody > > > > Requestors: rkleemann@gmail.com > > > > Status: new > > > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > > > > > > > > > > > It would be nice if numbers were aligned in a sensible way, on the
> > > decimal
> > > > point. Currently, all numbers are left-aligned, which makes sense in
> > the
> > > > simple case, but it would be nice if the following code aligned
> > properly:
> > > > > > > > my $price = 102.99; > > > > my $adjustment = -2.99; > > > > my $tax = 1.0775; > > > > my $final = ( $price + $adjustment ) * $tax; > > > > > > > > > > > > Of course, there is some question about how to align some of the more > > > > elaborate number formats: > > > > > > > > my $avagadro = 6.022140857E23; > > > > my $YYYYddd = 2018.156; > > > > my $pi = 3.14159265; > > > > > > > > my $green = 0x00ff00; > > > > my $rwxrw_rw_ = 0766; > > > > my $escape = 0b00011011; > > > > > > > > > > > > I think I've aligned them in a way that makes sense here, but I could
> > see
> > > > arguments for other alignments. > > > > > > > > Bob > > > > > > > >
> > > > > >
> > > >
> >

Message body is not shown because it is too large.

Bob, Those are possible workarounds, but there are some problems. One thing is that many programmers are working on code that they inherited from someone else and probably don’t want to make such detailed changes to keep it from formatting badly. A problem with inserting blank lines to break alignment is that this also breaks the alignment of the equals signs, and one thing I’ve learned is that most people really want the equals aligned. I think that the potential for lists of numbers to look bad is high, and while blocking off selected lists with the #<<< and #>>> symbols is possible, it puts the burden of formatting the list completely on the programmer. For large lists, say 1000 lines long, this isn’t practical. Steve
Subject: Re: [rt.cpan.org #125497] Support aligning numbers correctly
Date: Fri, 8 Jun 2018 09:28:20 -0700
To: bug-Perl-Tidy [...] rt.cpan.org
From: Bob Kleemann <rkleemann [...] gmail.com>
If people are reformatting the code, then I would think they're open to modifications that make the code more readable/understandable. In that case, adding blank lines or no-format sections shouldn't be much of an effort. Still, it's not something that everybody wants, which is why making it a switch that can be turned on/off at will would be sensible. Currently I know that if I am reformatting a section of code with numbers, I'll have to go back and manually realign the numbers. It's annoying, but not the end of the world. However, it is something that the computer should be able to do for me. On Fri, Jun 8, 2018 at 6:09 AM Steve Hancock via RT < bug-Perl-Tidy@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=125497 > > > Bob, > Those are possible workarounds, but there are some problems. > > One thing is that many programmers are working on code that they inherited > from someone else and probably don’t want to make such detailed changes to > keep it from formatting badly. > > A problem with inserting blank lines to break alignment is that this also > breaks the alignment of the equals signs, and one thing I’ve learned is > that most people really want the equals aligned. > > I think that the potential for lists of numbers to look bad is high, and > while blocking off selected lists with the #<<< and #>>> symbols is > possible, it puts the burden of formatting the list completely on the > programmer. For large lists, say 1000 lines long, this isn’t practical. > > Steve >