Pre-release of pragmatic module base::hasa

Discussion in 'Perl Misc' started by Anno Siegel, Mar 7, 2004.

  1. Anno Siegel

    Anno Siegel Guest

    I am preparing a pragmatic module "base::hasa" for release on CPAN. As
    usual at this stage, there is an urge to get some feedback before casting
    things in stone. ("Cast in stone"? Hmmm.) So I have put up a pre-release
    under

    http://www.tu-berlin.de/~siegel/clpm/base-hasa/

    From the doc:

    NAME
    base::hasa - 'Turn has-a relation into is-a (experimental)'

    SYNOPSIS
    package My::Class;

    # My::Class wants to inherit from Base::Class.
    # There is a has-a relation to Base::Class in the sense that
    # there is a method "hasa_method" in My::Class that returns
    # a Base::Class object.
    # To establish inheritance:

    use base::hasa ( 'Base::Class' => 'hasa_method');

    DESCRIPTION
    "base::hasa" establishes an "is-a" relationship with the base class
    "Base::Class". In addition, inherited methods are channeled through
    the "has_a" method.

    Thus, if "foo" is a method of "Base::Class", it is now immediately
    applicable to an object $mine in your inheriting class "My::Class":

    $mine->foo( ...);

    is equivalent to

    $mine->hasa_method->foo( ...);

    [...]

    Note that with has-a inheritance, knowledge about the base class is
    entirely encapsulated in the has-a relationship. This is no matter of
    course in Perl OO.

    [see full text at the URL above]

    I'd be thankful if anyone could find the time and interest to take a look.

    The module is functional, but it is barely debugged and I would not be
    surprised if it broke easily. Bug reports will be gratefully accepted,
    but that is not my main reason for posting. I'll be writing tests for the
    next few days anyway...

    I have the feeling that base::hasa proves something about Perl OO that
    might have been doubted, but I can't quite put my finger on it. "You
    never could inherit with knowing less about your base class" is a
    short way of putting it. I call this, somewhat clumsily, "has-a
    inheritance". The (preliminary) section COGITATIONS in
    the doc contains more on this. I'd be particularly grateful for
    thoughts about what role "has-a inheritance" plays in the greater scheme
    of things OO.

    Oh, something else... I wrongly thought that Time::piece was a standard
    module, and the documentation and examples (in examples/ex_*) freely use
    it. You may want to get it from CPAN if you want to play with base::hasa.
    Sorry about that.

    Anno
     
    Anno Siegel, Mar 7, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    972
    nishit
    Aug 9, 2006
  2. Volkmann, Mark
    Replies:
    0
    Views:
    120
    Volkmann, Mark
    Aug 4, 2003
  3. Dmitry N Orlov
    Replies:
    1
    Views:
    93
    Dave Thomas
    Dec 26, 2003
  4. Pedro Baldanta
    Replies:
    0
    Views:
    151
    Pedro Baldanta
    Feb 9, 2004
  5. Shannon Fang
    Replies:
    3
    Views:
    107
    cyberco
    Dec 8, 2005
Loading...

Share This Page