use style;

TeeJay on 2003-02-25T16:19:05

we've just been discussing the idea of a 'style' pragma that warns when you use $_ instead of a named variable, use map/grep for side effects or other nasty perl abuse.

then you could have:
use style;

.. nice code ..

NASTY: {
use no style;

.. nasty code ..

}

How cool would that be ?


the underscore thing was already implemented

merlyn on 2003-02-25T16:36:26

I don't recall the name, and it was about five or six years ago. Handled by tying $_, if I recall.

Re:the underscore thing was already implemented

davorg on 2003-02-25T17:26:24

Underscore.pm (named so it could be invoked with no Underscore) is a demonstration of tieing scalars in chapter 14 of Programming Perl (3ed).

Doesn't seem to have made it to CPAN yet tho' :)

Re:the underscore thing was already implemented

TeeJay on 2003-02-25T17:34:53

cool!

if only I had 3rd edition instead of 2nd..

anyone know where I can get some pointers or a how to on building and implementing a perl pragma or language filter ?

style sucks

belg4mit on 2003-02-25T17:02:53

Style is just another word for taste,
and there's no accounting for it.

Re:style sucks

TeeJay on 2003-02-25T17:23:51

I think it would be useful in a lot of areas, particularly where you have a company coding standard.

I have worked to coding standards a few times and have never really had any complaints apart from the shocking hoops required to implement anything useful in asp/vbscript.

Of course, you realise...

pdcawley on 2003-02-25T21:05:02

That good Perl 6 style will almost certainly involve using $_ in way more places...
given $foo {
   .bar;
   .baz;
   .quux;
}
Admittedly, the $_ is invisible in most such examples, but that doesn't mean it isn't there.

Underscore

vsergu on 2003-02-28T01:43:59

You're comparing use of $_ with use of map() and grep() in void context? To me, writing Perl without $_ is like writing English without pronouns. It's hardly a mark of good style.

Re:Underscore

TeeJay on 2003-02-28T09:04:33

I mean, often I see $_ used and modified 5 times in a dozen lines, this is a pig when a program has evolved over time - named variables are usually preferably 9 times out of 10.