in reply to variable "inheritance"; viral $VERSION

Why would you like this?

The point of $VERSION is to document what version of the code you have. When the $VERSION of one package reflects the version of a file appearing elsewhere you make it even easier for $VERSION to not represent what it is supposed to.

Why do you want a $VERSION with these properties?

If you want to do something so counterproductive, you certainly can. One appropriately silly way is to create a module named "am.pm" with a method named "I" which loads a module, inherits from it, and sets $VERSION. Then in every module you only need:

package Bar; use am; I am "Foo"; ...
The implementation of am::I is left as an exercise for the reader.

Replies are listed 'Best First'.
Re: Re: variable "inheritance"; viral $VERSION
by amackey (Beadle) on Mar 09, 2003 at 03:12 UTC
    You didn't read my original post carefully. I don't need to implement "I am 'Foo'", I can simply "use My::Package::Version" wherever I want it.

    The classes in my package all have "My::Package::*" names, and I only want $VERSION to propagate through all of these packages, not any other. I want a simple way to keep $VERSION "synchronized" throughout all classes of my package, without having to type something in all of them.

      I did read your original post.

      My suggestion adds typing. Yes. It also removes typing. You no longer need the "use Foo" line. You no longer need to declare your @ISA. The typing saved exceeds the typing added. I consider that reasonable if your intention is to save typing.

      Now can you explain why on Earth you would want this?

        > Now can you explain why on Earth you would want this?

        The original intent stems from the fact that My::Package::* classes contain hundreds of classes (i.e. .pm files). But 95% of these classes inherit from one or two base classes. I was merely interested in probing whether there was a solution by which I could alter the base classes, and have the desired effect in all subclasses, without altering 100+ files (although it would be trivial to add one or two lines to each, following every "package Foo" line).