in reply to Re^4: Beyond Inside-Out
in thread Beyond Inside-Out

In general, the Alter-approach assumes that methods are compiled in the class their name resides in.

That assumption breaks badly for classes that "mix-in" methods from other modules. Plug-ins (e.g. many of the web frameworks) would be a good example of this kind of thing, where a class imports one or more methods from the plug-in.

-xdg

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Replies are listed 'Best First'.
Re^6: Beyond Inside-Out
by Anno (Deacon) on May 30, 2007 at 14:10 UTC
    Methods imported as plug-ins would have to go through a well-defined interface, like a set of pre-appointed methods, to work with any class. That would continue to work with Alter-based classes. By name and purpose, a "plug-in" can't make assumptions about the makeup of the objects it will work with. I don't see a problem.

    The remark you quoted, "...the Alter-approach assumes that methods are compiled in the class their name resides in" concerns only code that accesses the object data directly. An imported method won't do that.

    Anno

      By name and purpose, a "plug-in" can't make assumptions about the makeup of the objects it will work with.

      See, for example, CGI::Application and how its plugins work. It's just Exporter bringing in things as requested.

      There's no reason that plugins couldn't be written to work with Alter in some way, but many existing plugins violate the assumption you stated.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        I think I must be missing something. I can't see what the problem is.

        Surely, the only thing that matters is that the property that method X deals with, is protected against being overwritten by any other method? As long as all other methods that want to access that property do so through the defined interface, rather than trying to access it directly, it shouldn't be a problem.

        Am I missing something?

        thanks

        clint

        See, for example, CGI::Application and how its plugins work

        I will, thanks. It's on Alter's to-do list.

        Anno