Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Things I Don't Use in Perl

by Anonymous Monk
on Aug 25, 2005 at 17:31 UTC ( [id://486655]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Things I Don't Use in Perl
in thread Things I Don't Use in Perl

The only reason you find those overloaded operators useful in the context of mathematics is that, in general, those symbols have already been overloaded as part of the standard mathematical notational. You're just conforming with a pre-existing convention; and convention is the only reason that such overloading appears natural to you.

For coding, I prefer to conform to the larger convention: I don't redefine symbols, because I don't need to redefine symbols, and the small gain I get from standardization with a localized mathematical convention is washed out by the big loss in standardization for general coding conventions.

I guess I don't like code that reads:

$x = $y + $z; # delete all files if running as user wilbur

which is exactly what operator overloading allows. Specifically, it removes any guarantees that I once had about what is being done to what, when. Instead, every single line is suspect, and must be read in a much wider context to verify correctness, which I see as a huge loss for maintainability.

Sooner or later, someone will make a deliberate or accidental piece of malicious code, and the easier it is to track it down, the better.

Replies are listed 'Best First'.
Re^4: Things I Don't Use in Perl
by Anonymous Monk on Aug 25, 2005 at 19:46 UTC
    I guess I don't like code that reads:
    $x = $y + $z; # delete all files if running as user wilbur
    Bad names are bad names whether they are overloaded or not. If you can't trust your programmer to choose sensible times to overload an operator, why would you trust him in selecting subroutine names at all?
    $x = fluffy_bunnies_are_cute($y,$z); # delete all files

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-29 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found