At Larry's (SVPUG) Perl6 talk last night, I was quite disturbed by his assertion that printf format statements would have to be wrapped in single quotes, because "%" would try to interpolate a hash value. He suggested, when asked, that folks could put in newlines as follows:
'yada yada yada \qq{\n}' This seems pretty ugly to me (Randal didn't like it much either :-) and I think Larry will get some heat unless he finds a cleaner way for printf fans to encode newlines. Some possibilities include: <DUCKING> * Defining some '%' operators (e.g., %n and %t) for commonly-used control characters. * Letting printf recognize escape sequences (e.g., '\n'). * Using a character other than '%' for format specifications. </DUCKING> Going a bit further afield, I also started thinking about the general nature of printf. I've been using this basic syntax since 1970 (in the form of Fortran's FORMAT statements :-), so I'm pretty comfortable with it. OTOH, I don't like the fact that the format specifications can become widely separated from the variables they reference. With all of Larry's talk about making "x" mode the standard in REs and having more "pair-based" syntax here and there, I started thinking about a replacement for printf, as: printx( 'The value of $foo is %f7.3; ', $foo, 'the value of $bar is %f7.3.%n', $bar ); printx( 'The values of $foo and $bar are %f7.3 and %f7.3, ', $foo, $bar, 'but the value of $baz is %f7.3%n', $baz ); Each printx argument could be either a string or a variable. If the string contained one or more format specifications, succeeding arguments would be formatted through them. Note that I'm suggesting a new function name because printf has a little-used capability that could conflict with my proposed syntax: "The format string is reused as often as necessary to satisfy the arguments." Anyway, that's my idea; what's yours? -r -- email: [EMAIL PROTECTED]; phone: +1 650-873-7841 http://www.cfcl.com/rdm - my home page, resume, etc. http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection