Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

Replies are listed 'Best First'.
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.

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>

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://494891]
[choroba]: I don't believe modules with syntax errors in Synopsis

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2017-02-27 11:58 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (383 votes). Check out past polls.