Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Re: printf vs. sprintf

by chipmunk (Parson)
on Feb 10, 2001 at 19:57 UTC ( #57628=note: print w/replies, xml ) Need Help??


in reply to Re: Re: printf vs. sprintf
in thread printf vs. sprintf

The explanation I remember from perl5-porters for this odd difference in behavior involves the optional filehandle argument for printf. The way prototypes were designed for the builtin functions, a prototype which allows for an indirect object has to specify list context for all the regular arguments. Since sprintf doesn't have an optional file handle argument, its prototype specifies a scalar for the first argument, and a list for the remaining arguments.

So, this difference in behavior between printf and sprintf is more by accident than by design. While the prototype for sprintf could be changed to match the prototype for printf, doing so would break backwards compatibility, particularly where the first argument to sprintf is a subroutine call.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://57628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2023-02-02 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (17 votes). Check out past polls.

    Notices?