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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
"Overloading is something applied to objects, not operators

" There's a concept called "Operator Overloading" that allows you to provide your own versions of operators to perform operations on class objects such as addition and subtraction of these objects lest Perl would treat these objects as strings that describe the class, a "string" here represents implementation and memory address (aka, references). If an operator is not overloaded and you called say + or - to add or subtract two objects (e.g defined data types) Perl would add/subtract on something like "Date=HASH(0x80f11fc)" ergo the need for Operator overloading which is described as:

"When you overload one of Perl's built-in operators, you define how it behaves when it's applied to objects of a particular class", from Programming Perl.

However, it seems that with overloading, there's a mixed statement because others describe it as:

"The module overload.pm is a standard part of the Perl distribution. It allows your objects to define how they will react to a number of Perl's operators. " from Perl.com

"the only kind of ‘operators’ that can be defined in Perl are prefix, and their names must be alphanumeric"

You can define addition and subtraction operators, built-in functions, prefix and post fix operators and around 50 other functions out there...

I think the entire concept is full of hassles that can be circumvented otherways around, but this is a SWAG for I don't have such information...and this discussion is amazing and informative... keep it going....


In reply to Re^3: Hints Towards Writing a Module with New Operators by Anonymous Monk
in thread Hints Towards Writing a Module with New Operators by swampyankee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2021-05-17 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (152 votes). Check out past polls.

    Notices?