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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Does your approach supports inheritance? multiple inheritance?

Yes and yes. For example:

use strict; use warnings; use Class::InsideOut::Accessor; { package Square; use base qw(Class::InsideOut); my (%x, %y, %size) : Field; sub new { bless [], shift }; }; { package Coloured; use base qw(Class::InsideOut); my %colour : Field; }; { package ColourSquare; use base qw(Square Coloured); }; my $o = ColourSquare->new; $o->x(10); $o->y(12); $o->size(6); $o->colour("red"); print "the colour is ", $o->colour;
Does Abigail-II's approach supports multiple inheritance?

Yes (and my method is Abigail-II's method with some syntactic sugar and a different DESTROY mechanism).

The advantage of doing it this way is that some kinds of problems caused by the traditional hash mechanism disappear because it is guaranteed that there is no sharing of attributes between classes.

One of the problems of using a traditional hash is that if two different classes use the same hash key to index an attribute then you cannot directly inherit from both of them (because they try and use the same bit of the hash for different purposes). You can use things like Class::Delegation to get around this problem, but it is more work - and tracking down the bug can take time.

Of course, all this depends on what you mean by multiple inheritance! Some languages (e.g. Eiffel) have a far more flexible approach to MI than languages like C++, Java & Perl.

For example, Class::InsideOut doesn't support inheriting from a class multiple times and having multiple copies of the attribute. But this isn't supported in the perl hash-style object implementation either.

If you're interested in multiple inheritance I would spend some time introducing yourself to inheritance in Eiffel (this page has some pointers) which is the most comprehensive model of MI I've come across in any language. It's quite hard to do some things in perl that are trivial in Eiffel.... Hmmm... might be worth a meditation at some later date...

In reply to Re^2: Class::InsideOut - yet another riff on inside out objects. by adrianh
in thread Class::InsideOut - yet another riff on inside out objects. by adrianh

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 editor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2021-05-11 14:16 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (116 votes). Check out past polls.