develooper Front page | perl.perl5.porters | Postings from October 2011

[perl #100190] RFE: fix sprintf to be consistent with printf and be useful!

Thread Next
Father Chrysostomos via RT
October 15, 2011 23:02
[perl #100190] RFE: fix sprintf to be consistent with printf and be useful!
Message ID:
On Wed Oct 05 14:38:47 2011, Hugmeir wrote:
> On Sat, Oct 1, 2011 at 1:18 PM, Linda Walsh <>
> > [...]You CAN
> > pass an array to it, it just is BAD code -- it certainly doesn't
throw an
> > syntax error -- it allows an array there, which, "___is [almost]^ never
> > useful__".  [...]
> >
> >
> >
> You know.
> That's actually true.
> There's a bug in a handful of modules because of this; See
>\s*\%28%3F\s*\%40 and
> ?\s*\@%20lang:^perl$&type=cs
> Changing it takes two lines of code (regen/opcodes and t/op/cproto.t)
and a
> regen, plus doc/delta changes. I was under the impression that @ is a
> superset of $@, so there's no lost functionality either -- I'm running (a
> very slow) make test right now, and nothing is failing, so this behavior
> wasn't even tested for! (or I haven't reached that part yet, but
> op/sprintf.t and op/sprintf2.t passed without issues)
> And it's not like prototypes haven't been changed before (to tchrist's
> chagrin, e.g.
> So eh, any reason why this can't be changed?

Consider sprintf(get_format(), @args).  get_format might return
something else in list context.  That’s the kind of breakage we don’t want.

Also, does your experiment really work, or do you mess up the stack in
cases like this?

@a = ('%d', sprintf());

> If anyone needs a compat layer,
> I imagine it's trivial enough to provide through
> or somesuch.

What would prototype(\&CORE::sprintf) return?

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About