Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Speaking of aesthetics, I find that example ambiguous. It's not obvious to me whether push is a method that just so happens to have the same name as the push keyword (the one which works on arrays) or whether it's an alternate way of writing that keyword. Is that a method which operates on a container (the array) or an object (not really a container)?

First, I'm not suggesting that the example makes perfect sense. I didn't chose it, I just matched it.

That said, I have absolutely no problem with an object, (regardless of the internal representation), (re)using a perl keyword for one of its methods, provided that the semantic of that method match those of the keyword. After all, isn't the separation of namespaces one of the primary benefits of OO?

In fact, given that keyword 'push' has been used for the semantics of (various) ADTs (stacks, FIFOs, LIFOs, etc.) in many languages that long pre-dated Perl; and is still the opcode mnemonic used for the equivalent hardware stack operation in (probably) every assembler and hardware manual for every processor going; I think it would be quite silly not to use that well understood term for objects that implement semantically equivalent operations.

In my mind, one of Perl's OO flaws is unnecessarily confusing containers and objects. An object may have containers, but should it be one?

I'm of almost the diametrically opposed position. I think that reusing the familiar and well understood semantics of containers for for classes that represent collections is both eminently sensible and infinitely preferable to everyone inventing their own disparate terms and semantics.

Other languages are perfectly happy to reuse container semantics for OO-classes. In the case of C++ its just a shame that it took the language standard so long to catch up with the rest of the world; with the knock on affect that they've had to invent verbose terms -- push_back, push_front, pop_back, pop_front etc. -- to avoid conflicts with previous 'unsanctioned' libraries.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^4: Is auto-dereferencing worth forcing upgrades to newer versions of Perl? by BrowserUk
in thread Is auto-dereferencing worth forcing upgrades to newer versions of Perl? by boftx

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 How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found