Hi Uri and Philip (and Abimael),
On Monday 12 Apr 2010 10:32:36 Uri Guttman wrote:
> >>>>> "PP" == Philip Potter <[email protected]> writes:
> PP> On 12 April 2010 07:55, Uri Guttman <[email protected]> wrote:
> >>>>>>> "PP" == Philip Potter <[email protected]> writes:
> >> PP> On 12 April 2010 04:31, Uri Guttman <[email protected]> wrote:
> >> >>>>>>> "AM" == Abimael Martinez <[email protected]> writes:
> >> >>
> >> >> AM> print {$tmp} "$div_start";
> >> >>
> >> >> no need for the {} around a single scalar handle.
> >>
> >> PP> But it *does* comply with Perl Best Practices #136.
> >>
> >> PP> * It makes the filehandle obviously different from the other
> >> arguments PP> * It makes you less likely to accidentally put a wrong
> >> comma in: PP> print {$tmp}, $div_start;
> >> PP> * If you forget a comma on a print statement where you just meant
> >> to PP> print to STDOUT, it stands out as being wrong:
> >> PP> print $arg1 $arg2; # should have been print $arg1, $arg2; or
> >> print PP> {$arg1} $arg2
> >> PP> * IOW, it forces you to be more explicit about when you are
> >> printing PP> to a fh and when you are printing to STDOUT.
> >>
> >> PP> So there's at least 2 other people out there (Damian and me) who
> >> think PP> the OP's version is reasonable.
> >>
> >> and did you see my much shorter answer with no file handles at all??
>
> PP> How is that relevant to my point?
>
> because your point is moot with the much better solution. the OP is
> wandering around the woods with IO::File and handles and he doesn't even
> need them. also i didn't even mention that if you do use handles, you
> can do direct method calls which are even better than indirect with
> {}. indirect method calls are just fugly in perl and can cause problems
> in some cases (not with print but with regular classes/methods. so it is
> BEST to never even use them if you can help it. $fh->print works as long
> as the handle is opened normally and you load the IO::Handle module (or
> something similar). hell, i rarely use anything but write_file these
> days so don't have to worry about it.
>
> >> and PBP isn't always right. it is meant as a list of interesting
> >> suggestions to pick and choose from. read the intro to get that. also
> >> note that i was one of the tech editors of that book. i know it
> >> well. and i disagree with some of it too. damian is fine with that. :)
>
> PP> Where did I say PBP was always right? I just didn't want to let your
> PP> style argument be the only one in this thread, since there are
> clearly PP> people who disagree with you, too. TIMTOWTDI.
>
> i disagree with myself most of the time! i am my own stupid boss and
> stupid worker. try that on for size! :)
>
Can we please have a civil discussion without insulting the other party? For
the record, I believe that in the context of writing to filehandles, PBP is
right by saying that one should use << print {$fh} @strings; >> instead of
<< print $fh @strings; >> (without the curly braces), in order to prevent
human and compiler errors. But naturally, this is very close to a bike shed
colour argument: http://en.wikipedia.org/wiki/Parkinson%27s_Law_of_Triviality
and either way can be understood by both the programmer and the compiler. Also
see:
http://community.livejournal.com/shlomif_tech/35842.html
It's OK to comment on some sub-optimal code to correct it, but let's avoid
descending into back-and-forth nitpicking or worse - insults. Friends, again?
Regards,
Shlomi Fish
> uri
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
My Aphorisms - http://www.shlomifish.org/humour.html
Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/