Hi Rob,

On Wed, 24 Aug 2011 23:07:13 +0100
Rob Dixon <rob.di...@gmx.com> wrote:

> On 22/08/2011 10:29, Shlomi Fish wrote:
> > Hi Alan,
> >
> > On Mon, 22 Aug 2011 14:43:48 +0530
> > Alan Haggai Alavi<alanhag...@alanhaggai.org>  wrote:
> >
> >> Hello Shlomi,
> >>
> >>> It's a good idea to always use "last LABEL;" instead of "last;" (as well
> >>> as "next LABEL;" etc. in case more loops are added in between.
> >>> ⋮
> >>> http://perl-begin.org/tutorials/bad-elements/#flow-stmts-without-labels
> >>
> >> Now I understand why it is always good to label loops that use `last`,
> >> `next` or `redo`.
> >>
> >> Thank you. :-)
> >>
> >
> > Nice. And you're welcome.
> >
> > For more insights like this, read the rest of the
> > http://perl-begin.org/tutorials/bad-elements/ page, and also the book Perl
> > Best Practices by Damian Conway, from which I borrowed a lot of advice.
> 
> This recommendation worries me as, first of all, I can't remember seeing
> labels used either in this list (except to exemplify the concept) or in
> working code in the field. In my mind it belongs together with the
> deprecation of $_ as a measure to defend against otherwise
> poorly-written code.

I've used such labels for loops in all the posts to this list where I used
"last", "next" or "redo", and for all the code I write in production. It is
also recommended by Perl Best Practices.

I also tend to avoid using "$_" (except for map/grep/etc. where it is
required), because it can be clobbered and devastated too easily, which also
makes depending on it error prone.

> 
> Just as with pronouns in natural language, implicit operands in Perl
> allow the meaning of a program to be more lucid. Yes, if we are not
> careful we can sometimes write confusing English where it is unclear
> what 'it' or 'he' refers to, but the solution is always to restructure
> the sentence rather than simply use proper nouns everywhere.
> 

Well, an analogy between English and Perl can only go so far. When writing
code, it is more important to make sure the code is correct and remains
correct than that it would be slightly more lucid.  

> Shlomi, do you honestly give a label to every last, next etc. that you
> write in live code?

Yes, I do (I practise what I preach). Maybe I sometimes avoid labelling loops
in some one-off scripts, but all my CPAN code (at least those that I've written
since I've read PBP) does not contain implicit flow-control jumps. 

> 
> What worries me more is that, in continually referring to your own web
> site, you give your opinion more weight than it deserves. The existence
> of the site tells me only that you are interested in the Perl language
> and like to write about it. Those unfamiliar with the origin and status
> status of your writings will inevitably assume more credibility than
> they deserve.

Well, one of the reasons I've created http://perl-begin.org/ is so I would be
able to refer people to the various resources there, in order to educate them.
This is more convenient and more effective than repeating the same wordy
texts times and again. I don't see how my site is any less credible than
other resources you can find online and in printed books, which were written
by human beings just like me. Most of the pages on Perl-Begin mention my name
as the webmaster at the bottom, and I also think the information I'm giving
there is sound, and not misleading in any way.

Also see what I've written previously about it here:

http://www.nntp.perl.org/group/perl.beginners/2011/05/msg117240.html

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Best Introductory Programming Language - http://shlom.in/intro-lang

Satan condemned Hitler for a million years of writing XSLT.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to