Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.9k stars 538 forks source link

support printf ' (apostrophe) format flag for builtin commifying #15176

Open p5pRT opened 8 years ago

p5pRT commented 8 years ago

Migrated from rt.perl.org#127521 (status was 'open')

Searchable as RT127521$

p5pRT commented 8 years ago

From justincase@yopmail.com

As in C and shell\, the ' (apostrophe) format flag is used for​:

  Decimal conversions (d\, u\, or i) or the integral portion of a   floating point conversion (f or F) should be grouped and   separated by thousands using the non-monetary separator   returned by localeconv(3).

This would make it even easier to perform the common task of commifying numbers.

p5pRT commented 8 years ago

From @jkeenan

On Thu Feb 11 19​:38​:47 2016\, justincase wrote​:

As in C and shell\, the ' (apostrophe) format flag is used for​:

Decimal conversions (d\, u\, or i) or the integral portion of a floating point conversion (f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv(3).

This would make it even easier to perform the common task of commifying numbers.

I'm not sure I agree with the feature request\, but it would be interesting to learn why Perl differs from C and the shell in this regard.

-- James E Keenan (jkeenan@​cpan.org)

p5pRT commented 8 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 8 years ago

From @mauke

Am 13.02.2016 um 02​:49 schrieb James E Keenan via RT​:

On Thu Feb 11 19​:38​:47 2016\, justincase wrote​:

As in C and shell\, the ' (apostrophe) format flag is used for​:

Decimal conversions (d\, u\, or i) or the integral portion of a floating point conversion (f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv(3).

This would make it even easier to perform the common task of commifying numbers.

I'm not sure I agree with the feature request\, but it would be interesting to learn why Perl differs from C and the shell in this regard.

It doesn't really differ from C. The ' flag is not part of standard C. (I don't know how common this extension is in practice.)

-- Lukas Mai \plokinom@​gmail\.com

p5pRT commented 8 years ago

From justincase@yopmail.com

On Fri Feb 12 17​:55​:47 2016\, plokinom@​gmail.com wrote​:

Am 13.02.2016 um 02​:49 schrieb James E Keenan via RT​:

On Thu Feb 11 19​:38​:47 2016\, justincase wrote​:

As in C and shell\, the ' (apostrophe) format flag is used for​:

Decimal conversions (d\, u\, or i) or the integral portion of a floating point conversion (f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv(3).

This would make it even easier to perform the common task of commifying numbers.

I'm not sure I agree with the feature request\, but it would be interesting to learn why Perl differs from C and the shell in this regard.

It doesn't really differ from C. The ' flag is not part of standard C. (I don't know how common this extension is in practice.)

I didn't realize it wasn't part of the C standard. Apparently it is defined as an XSI extension [1]. I did verify that it is supported in C on Linux\, OS X\, FreeBSD\, and NetBSD. Other languages supporting it are Bash\, Zsh\, and awk.

[1] http​://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html

p5pRT commented 7 years ago

From justincase@yopmail.com

On Sat\, 13 Feb 2016 14​:46​:31 -0800\, justincase wrote​:

On Fri Feb 12 17​:55​:47 2016\, plokinom@​gmail.com wrote​:

Am 13.02.2016 um 02​:49 schrieb James E Keenan via RT​:

On Thu Feb 11 19​:38​:47 2016\, justincase wrote​:

As in C and shell\, the ' (apostrophe) format flag is used for​:

Decimal conversions (d\, u\, or i) or the integral portion of a floating point conversion (f or F) should be grouped and separated by thousands using the non-monetary separator returned by localeconv(3).

This would make it even easier to perform the common task of commifying numbers.

I'm not sure I agree with the feature request\, but it would be interesting to learn why Perl differs from C and the shell in this regard.

It doesn't really differ from C. The ' flag is not part of standard C. (I don't know how common this extension is in practice.)

I didn't realize it wasn't part of the C standard. Apparently it is defined as an XSI extension [1]. I did verify that it is supported in C on Linux\, OS X\, FreeBSD\, and NetBSD. Other languages supporting it are Bash\, Zsh\, and awk.

[1] http​://pubs.opengroup.org/onlinepubs/009695399/functions/fprintf.html

According to http​://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html this is now "supported on all POSIX.1-2008-conforming systems."