On 4 December 2010 16:29, Tom Christiansen <tchr...@perl.com> wrote:
> Yves wrote:
>
>> Well, that is not entirely correct. Some /are/ full blown programs.
>
> *Those* I do try to always my() or our() or state() or sometimes
> even local(), which is indeed appropriate in places:
>
>    use Carp qw< :DEFAULT cluck >;
>
>    if (something_or_other) {
>        local $SIG{__WARN__} = sub { cluck "untrapped warning explanation" };
>        local $^W = 1;
>        call_something_else();
>    }
>    # local()s pop once that last closing brace is done
>
>
> It's the isolated snippets like the zillion I last night pointed out in
> perlfunc where I feel all the declaration detracts from the point.
>
> If you believe that every possible example in Perl needs to be fully
> declared, than by all means do so.  But make sure you always start every
> snippet with
>
>    #!/usr/bin/env perl -CLA
>    use 5.010;
>    use utf8;
>    use strict;
>    use autodie;
>    use warnings qw<FATAL all>;
>    use open qw<IO :utf8 :std>;
>    END { close STDOUT }
>
> or whatever boilerplate is currently considered
> de rigeur by all those trendy mODERN pERL people.
>
> Can you truly argue that that would *help* everything?

I think we would both agree that that is way to much. And I
automatically assume code with "use utf8" in it is subtly broken until
proved otherwise anyway. :-)

In fact I suspect over a pint we would probably mostly agree about
what is too much. :-)

>  *  If so, what?
>
>  *  If not, then what is all the fuss about?

Well, we are discussing the location of the "sweet spot of balance"
between the competing demands on our documentation. I was reacting to
what seemed to me to be an extreme positioning of that sweet spot.

>>> But I guess the general population is dumbing down in at an
>>> alarming rate.
>
>> Whatever. :-)
>
> I'm with Abigail on this.  I was taught not to assume one's
> audience is full of idiots.  That doesn't mean to be overly
> clever, just not talk to down to them.
>
> This is no longer Convention Wisdom.  Now you must assume
> that nobody has an iota of a clue.

It is a better default. You can always skip over and ignore things you
know, but its hard to find out about things you have no clue about.

> While this may work for certain sorts of presentations, I
> believe it is at most approprate only at the initial stage
> of language acquisition.
>
> But it seems now that we are expected to treat people like
> babies their whole lives long.

Well thats the thing, you seem to be suggesting that we should treat
people as adults their whole lives long, which also doesn't make
sense.

Newbies aren't hardened veterans of the digital wars like you are. The
point being there are multiple audience for our documentation, we are
unlikely to make all of them happy at once. But again, its easier for
a veteran to ignore something that they know about than it is for a
newbie to find out about something that isn't explicitly noted.

> Isn't that what the argument really is here?

It may have transformed into that, but personally if I wanted a
discussion like that Id bring up politics with my dad.

I think the real argument here is about how accessible the
documentation is to beginners, and what assumptions we make about the
audience for our documentation.

> I feel like there is a certain contingent that holds Perl::Critic as
> some sort of holy scripture, golden^Wclay tablets full of Biblical
> injunctions that we must all slavishly follow if we are to be good
> little perlians and see the good programming medal bestowed upon us.

Well I can assure that PBP is one of the best ways to get a
reactionary comment from me too. But I really dont feel that "the docs
should use my vars, and use lexically scoped filehandles, insofar as
this does not distract from the core point being documented" is
particularly Perl::Critic/PBP related. It is easy, as I think Shlomi
did to go way to far. For instance, *I* think its a good think that
*your* examples use '||' and not 'or' for exception handling. I think
that is useful. However, I dont think any particular advantage is
served by using global vars or global filehandles.

>
> As you see, I disbelieve.  Utterly.

Disbelieve what? :-) Oh. I see, you mean the Official Party Line.

Well, that is just because you have not been assimilated yet. But you
will be assimilated. Or maybe exterminated. Depends which tv show you
prefer. ;-)

In all seriousness, I really think the whole PBP/Perl::Critic thing
got way out of hand. Instead of being a sensible tool for looking for
potentially dangerous constructs, or recommendations that increase
code re-use and like, it turned into a sort of holy war.

For instance, I have formed a style that says that assignment should
be no-whitespace-on-left. I formed this style because I often work on
code that mixes SQL and Perl together, (although an early education in
Pascal probably also contributes), and this helps me to distinguish
between an sql "=" and a perl "=", which do not have the same meaning.
So i would do this:

  my $sql= "select * from Foo where x = 1";

notice how the two uses of "=" have different whitespacing. PBP
apparently considers this spacing choice to be incorrect. I not so
humbly disagree. :-) So I can see how some of this stuff would annoy
you.

But on the other hand using lexical filehandles IMO means that people
dont fall into the trap of reusing handles. It also means that they
wont leave files open for the duration of the program if they do not
explicitly close it. It also tends to mean that code that formerly
would share a global filehandle now passes around a lexical filehandle
instead. This means its easy to trace process flow and see what does
what.

I think these concerns outweigh any other considerations, and as such
I basically do not use global handles beside STDOUT and friends. And I
think beginners should be strongly encouraged to do the same.

Similar argument for lexical variables.

Pretty much the rest of the things that Shlomi's "fixed" IMO amount to
the same thing as someone not liking the way I use whitespace with
assignment.

That is, something they should get over (if they aren't that smart) or
something they should learn from (if they are smart), even if they
ultimately reject it.

> --tom
>
> PS: Yves, you have written more than I have currently processed.
>    That doesn't mean I agree or disagree, just that I haven't
>    processed it yet.  I may do so later if it really seems
>    deserving.

Sure, no worries. :-) Hope you have a good weekend.

cheers,
Yves




-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Reply via email to