[m-rev.] request for opinions: string.format_table_max output

Peter Wang novalazy at gmail.com
Mon May 22 16:12:27 AEST 2023


On Sun, 21 May 2023 22:18:04 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>  This diff adds the first test in the test suite of format_table_max.
> For input for which format_table output
> 
> aaa|áaȧ|1111111|¹½⅓¼⅕⅙⅛|  1,300,000.00
> 
> format_table_max output
> 
> aaa|áaȧ|1111111|
>               ¹½⅓¼⅕⅙⅛|
>                     1,300,000.00
> 
> It is probably not visible in this email (but is visible in the diff)
> that each table column here does start at the correct offset from
> the start of the line, which is what the current code is trying to do.
> My question is: *should* it try to do this? I can see two alternatives
> that could be better in some respects.
> 
> A Don't split lines even if some columns are over their width limit.
>   Instead, just let such fields take more than their usual maximum width,
>   resulting in the same output as if somedid JJ in vim on the above
>   three-line output.
> 
>   Plus: each conceptual line gets output on one actual line. Minuses:
>   an overlong column will move later columns to the right, and the
>   is no way enforce an overall line limit.
> 
> B If *any* column is overlong, then take as many characters from each column
>   as that column's limit allows, and construct an output line as usual from that,
>   then repeat the process with any leftover characters as needed.
> 
>   Pluses: fully enforces column width limits; puts initial parts of each column
>   on same line. Minus: breaks the text of overlong columns, possibly at points
>   that are suboptimal for understanding.
> 
> Should we switch to either option A or B? Alternatively, should we have
> different functions for A, B and the status quo?
> 

I think we should do A (don't split rows across lines). There will be
situations where someone wants to do something else, but I disagree with
including table formatting in the standard library anyway.

> +cound_and_find_max_str_length(Str, Count0, Count, PrevMaxLen, MaxLen) :-

count

Peter


More information about the reviews mailing list