Duh v D'oh
Paul Makepeace
paulm at paulm.com
Fri Nov 7 17:08:33 GMT 2008
On Fri, Nov 7, 2008 at 12:45 PM, Eden Cardim <edencardim at gmail.com> wrote:
> On Thu, Nov 6, 2008 at 1:33 PM, Paul Makepeace <paulm at paulm.com> wrote:
> > Following on the theme from a conversation with Mark at Dim Sum today*,
> spot
> > the mistake I just wasted an hour on,
> >
> > my $publication_stats = [['Source', 'ID Publication', 'Article count']];
> > foreach my $given_source (%publication_map_by_name) {
> > push @$publication_stats, [$given_source,
> > $publication_map_by_name{$given_source},
> > $article_count_by_source{$given_source}];
> > }
> >
> > If it's not staring out at you, you're possibly also a python programmer.
> > Python here arguably DWIM better than perl.
> >
> > Paul
> >
> > * there's some mistakes where you at the end go "D'oh!" because perl is
> > messing you around with its weirdness or otherwise non-intuitive
> behavior.
> > "Duh" when you're messing around and just not paying attention.
>
> I wouldn't call that non-intuitive, it's a matter of culture. Perl
> coders are used to being verbose about whether they want keys/values
> from a hash. If someone changed the behavior to make a hash in list
> context return it's keys, you would confuse a lot of Perl programmers
> out there too. And I'm particularly fond of perl's behaviour because
> it allows interesting cookbook tricks such as
>
> %config = (%default, %user_provided)
I don't think that's so exciting that this equivalent isn't acceptable in
its stead,
config = default
config.update(user_provided)
I think I prefer the slightly more explicit nature of this way , even.
Would be interesting exercise to compare/contrast these perl idioms and
their Language X equivalents and see where perl really shines, or not.
P
>
> --
> Eden Cardim Need help with your Catalyst or DBIx::Class project?
> Code Monkey http://www.shadowcat.co.uk/catalyst/
> Shadowcat Systems Ltd. Want a managed development or deployment platform?
> http://edenc.vox.com/ http://www.shadowcat.co.uk/servers/
>
More information about the london.pm
mailing list