# 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
>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.)
--Eric
--
The only thing that could save UNIX at this late date would be a new $30
shareware version that runs on an unexpanded Commodore 64.
--Don Lancaster (1991)
---------------------------------------------
http://scratchcomputing.com
---------------------------------------------