Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: How can I inherit from Bit::Vector?

by Fastolfe (Vicar)
on Nov 05, 2001 at 02:34 UTC ( [id://123232]=note: print w/replies, xml ) Need Help??


in reply to Re: How can I inherit from Bit::Vector?
in thread How can I inherit from Bit::Vector?

Here's a patch for Bit::Vector that seems to add the proper support for inheritable class names. It breaks 4 tests in the test suite, but they seem to be testing for the ability of the module to not support this, so I'm going to ignore these. All functional tests pass.

--- Vector.old.xs Sun Nov 4 15:14:40 2001 +++ Vector.xs Sun Nov 4 15:29:51 2001 @@ -257,7 +257,7 @@ { handle = newSViv((IV)address); reference = sv_bless(sv_2mortal(newRV(handle)), - BitVector_Stash); + sv_isobject(class) ? SvSTASH(SvRV(class)) : gv_stashsv( +class, 1)); SvREFCNT_dec(handle); SvREADONLY_on(handle); PUSHs(reference);
Again, I'd prefer a real solution from the author, but this may work for you in the mean time.

Replies are listed 'Best First'.
Re: Re: Re: How can I inherit from Bit::Vector?
by toma (Vicar) on Nov 05, 2001 at 04:17 UTC
    Thanks for the help!

    Still, it seems that Bit::Vector seems designed not to allow inheritance. Almost all the methods, such as shift_left(), check to see that they are handed a genuine Bit::Vector. If it isn't a Bit::Vector an error is generated.

    I'm beginning to think that I need to use a different strategy. Perhaps I should make an object that has a USES_A rather than an IS_A relationship with Bit:Vector.

    It should work perfectly the first time! - toma

      Yah that approach would probably be best.

      I'd still be interested in hearing why the author chose to go through all of these hoops to prevent someone from inheriting Bit::Vector. This almost seems a bit silly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://123232]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found