Re: rethinking printf

2002-03-19 Thread Luke Palmer
On Mon, 18 Mar 2002, Jim Cromie wrote: > Rich Morin wrote: > > > At 11:24 PM -0500 3/6/02, Uri Guttman wrote: > > > >> qn would be just like qq but not allow any > >> direct hash interpolations (%foo or %foo{bar}). you can always get those > >> with $() if needed. this solves the common c

Re: rethinking printf

2002-03-19 Thread Jim Cromie
Rich Morin wrote: > At 11:24 PM -0500 3/6/02, Uri Guttman wrote: > >> qn would be just like qq but not allow any >> direct hash interpolations (%foo or %foo{bar}). you can always get those >> with $() if needed. this solves the common case with a minimal of noise >> and the uncommon case h

Re: rethinking printf

2002-03-14 Thread Adam Rice
Quoting Uri Guttman ([EMAIL PROTECTED]): > and interpolating $foo in a format is useful so that is not stopped. i > have used it for format precision values. i recently discovered that > perl still supports the c style of * meaning to use the next arg for the > precision/width value. i much prefer

Re: rethinking printf

2002-03-10 Thread Vicki Brown
Listmom tries to keep this a self-moderating list, but alas, Listmom has had a complaint. This thread started out as fun ("How Would YOU Do It?" is an acceptable topic for FWP) but has become more meta discussion and less fun with Perl. Please move any further design to [EMAIL PROTECTED] Thanks

Re: rethinking printf

2002-03-10 Thread ianb
On 10 Mar 02 at 11:14:26PM, Uri Guttman wrote: > i really think that the printf format spec is so standard and ingrained > that changing it with # for % or requiring \% is not a good idea. > > but then again, backwards compatibility is not a rule you must always > obey. i just think in this case

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "PS" == Peter Scott <[EMAIL PROTECTED]> writes: PS> At 01:39 AM 3/11/02 +0100, Eugene van der Pijll wrote: >> Why not replace the escape character '%' with '#'? No new quoting >> operators or functions to learn. PS> Beat me to it. >> And introduce a warning if there are >> no

Re: rethinking printf

2002-03-10 Thread Peter Scott
At 01:39 AM 3/11/02 +0100, Eugene van der Pijll wrote: >Why not replace the escape character '%' with '#'? No new quoting >operators or functions to learn. Beat me to it. >And introduce a warning if there are >no #'s in the format string. Maybe if it's a constant, but not if you're doing someth

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "BD" == Brent Dax <[EMAIL PROTECTED]> writes: BD> Uri Guttman: BD> # $prec = %hash{width} ; BD> # sprintf( qf"%${prec}s", $string); BD> # BD> # sprintf( "\%${prec}s", $string); BD> # BD> # is one of your alternatives. :-/ BD> You forgot one. BD> sprintf('%'_%hash{width

RE: rethinking printf

2002-03-10 Thread Brent Dax
Uri Guttman: # > "BD" == Brent Dax <[EMAIL PROTECTED]> writes: # # BD> I think qn counts as weird syntax. I ask again, what's # wrong with one # BD> of: # # BD> sprintf("%hash\%s", $string); # # BD> sprintf(%hash.'%s', $string); # BD> sprintf('%s%s', _%hash,

Re: rethinking printf

2002-03-10 Thread Eugene van der Pijll
Why not replace the escape character '%' with '#'? No new quoting operators or functions to learn. And introduce a warning if there are no #'s in the format string. Eugene

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "BD" == Brent Dax <[EMAIL PROTECTED]> writes: BD> I think qn counts as weird syntax. I ask again, what's wrong with one BD> of: BD> sprintf("%hash\%s", $string); BD> sprintf(%hash.'%s', $string); BD> sprintf('%s%s', _%hash, $string); what if you want to use %hash{width}

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "YS" == Yitzchak Scott-Thoennes <[EMAIL PROTECTED]> writes: YS> Uri Guttman <[EMAIL PROTECTED]> wrote: >> i disagree. but we shall see if larry is listening to this thread and >> will back away from hash interpolation or take some of our suggestions >> that make it work without kil

Re: rethinking printf

2002-03-10 Thread Rich Morin
Earlier, I mentioned the idea of replacing overly complicated "printf"s with a "print" and some "f" function calls, as: { $a=1828; $b=45; print f("pi=%8.6f, ",355/113), f("e=2.7$a$a$b%d$b\n", $b*2); } Now, "f" is really just shorthand for "sprintf", but cr

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
In article <[EMAIL PROTECTED]>, "Brent Dax" <[EMAIL PROTECTED]> wrote: > >There's only a clash if you double-quote the format string anyway, which >is a rare thing to need to do at all. I'd expect that a hefty percentage of format strings have a \n.

RE: rethinking printf

2002-03-10 Thread Brent Dax
Abigail: # I'd think it would be much better that '%' followed by a word *not* # followed by a { isn't interpolated. Granted, you cannot do # interpolation # of hashes (well, one could always write "@{[%hash]}", just # like in perl5, # and there's little change of clashing with printf formats. # T

RE: rethinking printf

2002-03-10 Thread Brent Dax
Uri Guttman: # i disagree. but we shall see if larry is listening to this thread and # will back away from hash interpolation or take some of our suggestions # that make it work without killing format strings. i hate to see a # special call or wierd syntax for that. my qn (or qf) # suggestion seem

Re: rethinking printf

2002-03-10 Thread Rafael Garcia-Suarez
I just wrote : > > qc// ? (Mnemonic : "Quote like in C") Couldn't resist to implement this ;-) There are probably bugs (not speaking about trigraphs) but this package makes available a qc// operator that should do this. package QC; use strict; use warnings; use Exporter; use Sub::Quotelike; o

Re: rethinking printf

2002-03-10 Thread Rafael Garcia-Suarez
Keith C. Ivey wrote in perl.fwp: > Uri Guttman <[EMAIL PROTECTED]> wrote: > >> i hate to see a >> special call or wierd syntax for that. my qn (or qf) suggestion seems >> to have some backing and it is clean and unobtrusive. > > Your qn() suggestions seems weird itself. It's too strange to have

Re: rethinking printf

2002-03-10 Thread Yitzchak Scott-Thoennes
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Lines: 17 In article <[EMAIL PROTECTED]>, Uri Guttman <[EMAIL PROTECTED]> wrote: >i disagree. but we shall see if larry is listening to this thread and >will back away from hash interpolation or take some of our suggestions >that make

Re: rethinking printf

2002-03-10 Thread Keith C. Ivey
Uri Guttman <[EMAIL PROTECTED]> wrote: > i hate to see a > special call or wierd syntax for that. my qn (or qf) suggestion seems > to have some backing and it is clean and unobtrusive. Your qn() suggestions seems weird itself. It's too strange to have a special quoting method that allows inter

Re: rethinking printf

2002-03-10 Thread Uri Guttman
> "a" == abigail <[EMAIL PROTECTED]> writes: a> On Wed, Mar 06, 2002 at 11:15:30PM -0500, Uri Guttman wrote: >> >> good point. $() can still wrap that but then there has to be a balance >> between printf strings and double quoters. how about this wacky idea: >> >> make a new ty

Re: rethinking printf

2002-03-10 Thread abigail
On Wed, Mar 06, 2002 at 11:15:30PM -0500, Uri Guttman wrote: > > "BL" == Bart Lateur <[EMAIL PROTECTED]> writes: > > BL> On Wed, 6 Mar 2002 17:57:07 -0500, Uri Guttman wrote: > >> how often will you need to interpolate a hash? > > BL> A whole hash: quite rarely. A hash item: a LOT. Don

Re: rethinking printf

2002-03-08 Thread Matthew Wickline
[EMAIL PROTECTED] wrote: > why not qf for format strings then For some reason, I thought Schwern would be the one to suggest a queef operator ;) -matt PS: that may be a US-specific bit of slang http://google.com/search?q="a+queef+is";

Re: rethinking printf

2002-03-07 Thread Yitzchak Scott-Thoennes
In article <[EMAIL PROTECTED]>, =?koi8-r?B?RG1pdHJ5IEtvaG1hbnl1ayDkzcnU0snKIOvPyM3BzsDL?= <[EMAIL PROTECTED]> wrote: >On Wed, Mar 06, 2002 at 08:56:18PM -0800, Yitzchak Scott-Thoennes wrote: >> >Apparently, when I did a "man printf", I got the one in FreeBSD's Section 1: >> >> The format str

Re: rethinking printf

2002-03-06 Thread Ariel Scolnicov
Paul Makepeace <[EMAIL PROTECTED]> writes: > On Wed, Mar 06, 2002 at 09:45:18AM -0800, Rich Morin wrote: > > He > > suggested, when asked, that folks could put in newlines as follows: > > > > 'yada yada yada \qq{\n}' > > I meant to add this in last time: There is also the option of having an

Re: rethinking printf

2002-03-06 Thread Dmitry Kohmanyuk Дмитрий Кохманюк
On Wed, Mar 06, 2002 at 08:56:18PM -0800, Yitzchak Scott-Thoennes wrote: > >Apparently, when I did a "man printf", I got the one in FreeBSD's Section 1: > >> The format string is reused as often as necessary to satisfy the > >> arguments. Any extra format specifications are evaluated

Re: rethinking printf

2002-03-06 Thread Rich Morin
At 8:56 PM -0800 3/6/02, Yitzchak Scott-Thoennes wrote: >Does it in fact reuse the format on your system? % printf '%d %d\n' 1 2 3 1 2 3 0 -- 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,

Re: rethinking printf

2002-03-06 Thread Dmitry Kohmanyuk Дмитрий Кохманюк
On Wed, Mar 06, 2002 at 11:24:57PM -0500, Uri Guttman wrote: > that is another point. not allowing a complete hash to interpolate. but > what defines that? what if you wanted %s{bar} and that was a format and > not a hash and in a double quoted string? my proposal handles that well > with no major

Re: rethinking printf

2002-03-06 Thread Yitzchak Scott-Thoennes
In article , Rich Morin <[EMAIL PROTECTED]> wrote: >At 5:27 PM -0800 3/6/02, Yitzchak Scott-Thoennes wrote: >>>"The format string is reused as often as necessary >>> to satisfy the arguments." >> >>Where did you get that? Not true for Perl or C. >

Re: rethinking printf

2002-03-06 Thread Rich Morin
At 11:24 PM -0500 3/6/02, Uri Guttman wrote: > qn would be just like qq but not allow any >direct hash interpolations (%foo or %foo{bar}). you can always get those >with $() if needed. this solves the common case with a minimal of noise >and the uncommon case has a simple out of using $(). no

Re: rethinking printf

2002-03-06 Thread Rich Morin
At 5:27 PM -0800 3/6/02, Yitzchak Scott-Thoennes wrote: >>"The format string is reused as often as necessary >> to satisfy the arguments." > >Where did you get that? Not true for Perl or C. Apparently, when I did a "man printf", I got the one in FreeBSD's Section 1: >PRINTF(1)

Re: rethinking printf

2002-03-06 Thread Uri Guttman
> "BD" == Brent Dax <[EMAIL PROTECTED]> writes: BD> Uri Guttman: BD> # printf "%d hash is $(%foo.string)", $bar ; BD> # BD> # no ambiguity and no confusion. how often will you need to BD> # interpolate a BD> # hash? BD> As others have pointed out, %foo{BAR} has to work.

Re: rethinking printf

2002-03-06 Thread Uri Guttman
> "BL" == Bart Lateur <[EMAIL PROTECTED]> writes: BL> On Wed, 6 Mar 2002 17:57:07 -0500, Uri Guttman wrote: >> how often will you need to interpolate a hash? BL> A whole hash: quite rarely. A hash item: a LOT. Don't forget that BL> $foo{BAR} will now become %foo{BAR} good point. $()

Re: rethinking printf

2002-03-06 Thread Yitzchak Scott-Thoennes
In article , Rich Morin <[EMAIL PROTECTED]> wrote: >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 sati

RE: rethinking printf

2002-03-06 Thread Brent Dax
Uri Guttman: # printf "%d hash is $(%foo.string)", $bar ; # # no ambiguity and no confusion. how often will you need to # interpolate a # hash? As others have pointed out, %foo{BAR} has to work. But I have another question for you: what's wrong with sprintf '%d hash is %s', $bar,

Re: rethinking printf

2002-03-06 Thread Bart Lateur
On Wed, 6 Mar 2002 17:57:07 -0500, Uri Guttman wrote: >how often will you need to interpolate a hash? A whole hash: quite rarely. A hash item: a LOT. Don't forget that $foo{BAR} will now become %foo{BAR} -- Bart.

Re: rethinking printf

2002-03-06 Thread Uri Guttman
> "BC" == Bernie Cosell <[EMAIL PROTECTED]> writes: BC> I wonder if the solution is to look at it the other way: that you BC> have to do something to get interpolation to happen. If we look BC> at it from the old adage of making the more common things simpler, BC> at least in my co

Re: rethinking printf

2002-03-06 Thread Bernie Cosell
On 6 Mar 2002, at 9:45, Rich Morin wrote: > 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 coul

Re: rethinking printf

2002-03-06 Thread Paul Makepeace
On Wed, Mar 06, 2002 at 09:45:18AM -0800, Rich Morin wrote: > He > suggested, when asked, that folks could put in newlines as follows: > > 'yada yada yada \qq{\n}' I meant to add this in last time: There is also the option of having an additional function that adds the newline in, e.g. WriteLi

Re: rethinking printf

2002-03-06 Thread Andrew Pimlott
On Wed, Mar 06, 2002 at 09:45:18AM -0800, Rich Morin wrote: > 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

Re: rethinking printf

2002-03-06 Thread Randal L. Schwartz
> "Rich" == Rich Morin <[EMAIL PROTECTED]> writes: Rich> This seems pretty ugly to me (Randal didn't like it much either :-) Yup. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/> Perl/Unix/security consult

Re: rethinking printf

2002-03-06 Thread Rich Morin
>I like the idea, but wonder how to avoid problems that could arise with >things like, > >$raise = "15%"; >printx( > 'My raise was %s this year!', $raise >); In this particular case, there would be no problem, because $raise would be "consumed" by the "%s" in the initial string and would no

Re: rethinking printf

2002-03-06 Thread Paul Makepeace
On Wed, Mar 06, 2002 at 09:45:18AM -0800, Rich Morin wrote: > 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

rethinking printf (oops)

2002-03-06 Thread Rich Morin
Serves me right for composing a posting while I'm still half asleep: s/%f7.3/%7.3f/g -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

rethinking printf

2002-03-06 Thread Rich Morin
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 \