----- Original Message ----- 
From: "Eric Wilhelm" <[EMAIL PROTECTED]>
To: <inline@perl.org>
Sent: Wednesday, June 22, 2005 2:32 AM
Subject: Re: Accessing info contained in objects


> # The following was supposedly scribed by
> # Sisyphus
> # on Tuesday 21 June 2005 02:50 am:
>
> >----- Original Message -----
> >From: "Eric Wilhelm" <[EMAIL PROTECTED]>
> >
> >> Could you tie() it?
> >
> >If there's one thing I comprehend more poorly than 'pack' and
> > 'unpack', it's 'tie'.
>
> perldoc perltie
> perldoc Tie::Array
>

Read the first a few times (never read the second) - totally clueless as to
what it means but, in view of what you've written below, it looks like I'll
have to decipher it :-)

> >The beauty of that
> > approach is that the existing DESTROY() function copes perfectly with
> > the cleaning up of that "object packed with GMP objects" and the
> > problem with memory management simply ceases to exist.
> >The downside is that I didn't (and still don't) know how to access
> > from perl those GMP objects that are packed into the object returned
> > by the "real life" array_init() function.
>
> Yes.  The tied array seems (er) perfect.  That is, you need a blessed
> object of class GMP::Array, which has a base class GMP.
>
> The trouble is only in syntax, because you don't want @array, but
> instead $array = GMP::Array->new() (the oo name for array_init()), and
> then you'll want to be able to say $array->[4]->method().
>
> So, maybe you have a class GMP::Array::Tied which implements the tying?
> You'll have to play around and see what you can get away with.
>
> Maybe you're stuck with this two-variable interface:
>
>   my $obj = tie @somearray, GMP::Array;
>
> Which isn't soo bad.  You call the methods with $obj and go to
> individual values with @somearray.
>
> However, those individual values won't be GMP objects (in the perl
> blessed-object sense), but they could be if you wrote the accessor
> methods for your tied class as if they were constructors (read that
> with a grain of salt, I'm not exactly sure it would work.)
>

Thanks Eric.
As it stands, there is no blessing done on the perl side, there are no
methods (functions are called as functions), in fact there's no OO at all.
The only blessing that happens is when newSVrv() gets called - and that was
done simply to facilitate cleanup and operator overloading. If there's now
something to be gained by doing whatever it is you're telling me to do
(that's how well I understand it :-), then I had better do just that.

If there's some simple modification that could be made to the script I
posted at the start of this thread that can demonstrate something (anything)
relevant, then that would be an enormous help.

Cheers,
Rob

Reply via email to