home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!news!netlabs!lwall
- From: lwall@netlabs.com (Larry Wall)
- Newsgroups: comp.lang.perl
- Subject: Re: Is this a perl bug?
- Message-ID: <1992Dec12.072651.653@netlabs.com>
- Date: 12 Dec 92 07:26:51 GMT
- References: <1992Dec6.232905.13545@reed.edu> <1992Dec8.175616.20198@netlabs.com> <9212111642.AA27958@brimstone.unipalm.co.uk>
- Sender: news@netlabs.com
- Organization: NetLabs, Inc.
- Lines: 57
- Nntp-Posting-Host: scalpel.netlabs.com
-
- In article <9212111642.AA27958@brimstone.unipalm.co.uk> ian (Ian Phillipps) writes:
- : lwall@netlabs.com (Larry Wall) writes:
- :
- : >And why have I put off formats for so long? Guess where a lot of the
- : >most ancientest and most decrepitudinous code in Perl is.
- :
- : Why not write them in perl?
- : A few quick hacks, an eval, and away you go. Maybe.
-
- Well, in actual fact, in Perl 5, the tokener turns a format into a
- strange sort of subroutine, which calls one or more statements
- containing a list operator called "formline". You can call formline
- yourself if you want to do something funky.
-
- Similarly, when you say "\u\L$foo\E$bar", the tokener turns that into
- (ucfirst(lc($foo)) . $bar). You can call uc(), lc(), ucfirst() and
- lcfirst() yourself if you like. Similarly, `cat $foo` turns into
- something like backtick('cat ' . $foo), though I haven't actually put
- in a keyword to access that function yet. The m// and s/// stuff works
- similarly.
-
- Anyway, formats are completely rewritten now, and work, and I'm at 95.89%.
- I'm now to the point where I have to start putting in lexical scoping
- and references to make any more progress.
-
- The 3 tests that are still failing use most of the cpu time they would
- anyway, so I compared the timings of Perl 4 on the regression tests
- with Perl 5. With both compiled -g -DDEBUGGING, I got:
-
- Perl4: 11.4u 16.8s 0:48
- Perl5: 9.4u 10.5s 0:36
-
- For something that I've done almost no optimization on except for constant
- folding, that's not too shabby...
-
- I suspect that the difference in system time comes from longjmp() avoidance.
-
- : BTW - I've used most bits of Perl (but *foo='bar' still has me
- : baffled), but I've never actually *used* formats - although they've
- : appeared in early drafts of some of my efforts.
- :
- : In every case I've met, "printf" does what I want and formats don't,
- : mostly because of what happens when the variable is too wide for the
- : field - I'm in the "keep the data a blow the format" party.
-
- Hmm, I might be able to give you overflowable fields with the new
- format code. What about something like @<<<<*, analogous to the @*
- thingy? I suppose that would imply a minimum width of 2 for @*, but
- that's probably okay, since it would generally turn into 2 spaces that
- would get eaten up before the newline anyway.
-
- One could also imagine specifying that as *<<<<<, since ^<<<<* doesn't
- really make much sense, but I don't think I want to introduce another
- initial metacharacter. On top of which, ^###.#* does make some sense,
- not to mention cents.
-
- Larry
-