Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: On what column do you wrap your code?

by radiantmatrix (Parson)
on Feb 10, 2006 at 21:01 UTC ( #529463=note: print w/replies, xml ) Need Help??


in reply to On what column do you wrap your code?

I tend toward 80. Why? Hm, well...

  • 72 is much too short when using a 4-char indent level: two levels in and I end up wrapping simple open ... or die "Can't write $filename: $!" calls.
  • 78 would be ok, but WHY?
  • Anything over 80 seems impolitic; I can always expect that someone can view and edit an 80-column line, but much longer and I fear making a production for someone else to deal with my code.

So, I voted 80, but I'm not strict about it. If I'm maintaining code I try to derive and follow the existing wrapping rules (and other style elements). Some lines just feel like they need to be longer than 80 chars, and I'm willing to let those "break" the wrapping rules.

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet

Replies are listed 'Best First'.
Re^2: On what column do you wrap your code?
by Juerd (Abbot) on Feb 16, 2006 at 11:52 UTC

    78 would be ok, but WHY?

    The usual argument says stuff about terminals not being able to handle characters in the last column correctly (then why the hell HAVE that column?), and 80-2 allowing the text to still be 80 wide after adding "> ", the quotation mark used in email.

    However, I wouldn't even use such a terminal, and the quoting argument doesn't hold given replies to replies, when another "> " is added. And I indent all code (a habit I got from POD, and I like it) in mail anyway.

    So I think 78 makes no sense at all, and this is one of the guidelines in Perl Best Practices that I choose to ignore. It's 80 for me.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      My guess is 78 came about because 'diff' requires two columns for the '< ' and '> '. That seems sensible.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://529463]
help
Chatterbox?
[Eily]: you could tie a variable into not having the same value each time, if you like to make people who try to debug your code facepalm
[Corion]: perl -wle 'package o; use overload q("") => sub {warn "str"; ""}, bool => sub{warn "bool"; 1}; package main; my $o={}; bless $o => o; print "Yay" if ($o && !length($o))'
[Corion]: But people writing such code should document the objects they construct and why it makes sense for an object to be invisible as string while being true in a boolean context
[hippo]: That's equal parts clever and horrendous.
[Eily]: the overload version wouldn't return true with "$x" && !length $x though, I guess
[hippo]: The more I look at this code, the more $x is a plain old scalar and the more this condition will never be true. I'm calling it a bug at this point.
[hippo]: Thanks for your input which has soothed my sanity (a little)
[Corion]: Eily: Sure - if you force both things into stringy things, then you break that magic. But that would also mean that you changed the expression, as now $x = 0.00 will be true instead of false as it were before
[Corion]: Ah no, at least in my feeble experiments that doesn't change the meaning
[Corion]: We sell sanity in small packages ;)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-07-27 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (413 votes). Check out past polls.