in reply to Re^3: Object Method Call
in thread Object Method Call

So, one could say that  display($self) breaks inheritance.
It certainly does that if  display is a method.

This is often bad, but sometimes, it can be a useful trick.
Hm. Well, I would agree with the word bad, but I think I would delete often unless the goal of the trick is to confuse the heck out of yourself and everyone else. For me, it's hard enough to keep everything in OO programming straight without deliberately trying to trick myself.

I'm curious: Can you give an example of how this trick might be productively used?

Replies are listed 'Best First'.
Re^5: Object Method Call
by afoken (Chancellor) on Jul 27, 2009 at 19:33 UTC

    Hmmm, I remember having used that trick only once in my life, but the project has been administrated to dead (long story about clueless interns working as admins, dieing harddisks, missing monitoring systems, and insufficient backups). It was a crude class hierarchie that should have been refactored. At one point, the usual inheritance would have broken things if a certain method was overwritten. I don't remember the details and the sources are lost, but it was nasty and had a comment marking that trick as "evil but required".

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      evil but required
      Ah, yes. Now I know just the code you are talking about.