Changes between Version 1 and Version 2 of Ticket #3666, comment 114


Ignore:
Timestamp:
11/07/16 13:35:11 (4 years ago)
Author:
egmont
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #3666, comment 114

    v1 v2  
    77> In the very special case of {{{size_trunc_len()}}} and alike is that the passed {{{len}}} is given in bytes 
    88 
    9 What's the ''semantics'' of {{{len}}} here? Is it the number of ''available'' bytes in the output buffer, or is it the number of ''desired'' bytes to fill it up with? You're mixing the two! When thinking in bytes, the number of ''available'' bytes is 64 in the current code, whereas the number of ''desired'' (or ''maximum'') bytes to which to format the string does not make sense. Why would you want to ask the formatter "hey format me this number, I give use a quite large buffer, but make sure not to write more than 11 bytes"? No sense whatsoever. It's the desired UI look you care about, in some locales it'll take 8 bytes, in some it'll take 11, in some it'll take even more. The formatter will know this, why should the caller care? If you specify a limit ''in bytes'', it should be because of technical limitation (the buffer being finite long). 
     9What's the ''semantics'' of {{{len}}} here? Is it the number of ''available'' bytes in the output buffer, or is it the number of ''desired'' bytes to fill it up with? You're mixing the two! When thinking in bytes, the number of ''available'' bytes is 64 in the current code, whereas the number of ''desired'' (or ''maximum'') bytes to which to format the string does not make sense. Why would you want to ask the formatter "hey format me this number, I give you a quite large buffer, but make sure not to write more than 11 bytes"? No sense whatsoever. It's the desired UI look you care about, in some locales it'll take 8 bytes, in some it'll take 11, in some it'll take even more. The formatter will know this, why should the caller care? If you specify a limit ''in bytes'', it should be because of technical limitation (the buffer being finite long). 
    1010 
    1111Whereas, on the other hand, you might want to ask the same questions for ''width''. Here, the concept of ''available'' width in the buffer does not make any sense, whereas the ''desired'' width, to which to format the string (which is 8 in my recent example), is an important one.