Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Commonly accepted style guide?

by grinder (Bishop)
on Sep 25, 2005 at 09:21 UTC ( #494891=note: print w/ replies, xml ) Need Help??


in reply to Re: Commonly accepted style guide?
in thread Commonly accepted style guide?

cramming a dozen functions onto one line in some kind of clever but completely unreadable tangled chain

I'm not quite sure I'm in agreement with this one. It's not tangled, it flows from right-to-left. It's such a nice idiom that Perl 6 introduces the ==> operator, in order to reverse the flow. It will go from left to right, and I suspect the result will be much more readable.

And if you think it's a tangle, the style question at hand is that of the Correct Use of Whitespace. A well-indented chain of functions should be eminently readable.

massive amounts of referencing and dereferencing

No disagreement with this one. Programmers in C used to create intermediate typedefs in order to get around this problem (like a "pointer to array of functions returning an int with parameters of a pointer to a void function taking an int and an array of characters").

While this exact problem doesn't arise with Perl, the problem of decoding what a massive dereferencing statement is doing can be pretty brain-melting.

• another intruder with the mooring in the heart of the Perl


Comment on Re^2: Commonly accepted style guide?
Re^3: Commonly accepted style guide?
by Jenda (Abbot) on Sep 25, 2005 at 12:04 UTC

    <RANT>Considering how twisted the syntax of C types gets as soon as pointers, functions and arrays are involved using typedefs is pure self-defense. Hey, what's the syntactical difference between the declaration of a function returning a pointer to int and a pointer to function returning int? Seems to me someone failed to envision the posibility of types more complex than an array to foo or pointer to foo.</RANT>

    Jenda
    XML sucks. Badly. SOAP on the other hand is the most powerfull vacuum pump ever invented.

Re^3: Commonly accepted style guide?
by chester (Hermit) on Sep 25, 2005 at 16:29 UTC
    I agree that whitespace can be a big difference. That's actually my problem; if that was broken up into lines, I'd say it was mostly OK. If you get this:

    @_ = join "\n", map {/$complicated_regex/} split '', join ',', reverse sort map {lc} map {do_backflips($_)} keys %{ $var->{$something} } ;

    Imagine some more assignments on the left and some more semicolons on the right and it's pretty much equivalent to reading any other code (except that you have to read it backwards).

    I agree that even my first example as it stands isn't nearly as confusing as my second with the referencing. At least the flow of the first is linear; nesting things is much worse.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494891]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2014-08-23 19:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls