in reply to Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!

I dislike this whole idea because everything here is ultimately a global and subject to the global garbage collecting rules. I can see this being a serious issue for object oriented systems where it matters in which order object destruction occurs. PodMaster suggested in the other node that its possible to remove the global component from one of Symbol's gensym globs and I think that once that exists, this module can work. Until then... ick. Double ick.

  • Comment on Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!

Replies are listed 'Best First'.
Re: Re: Object::MultiType - Perl Objects as Hash, Array & Scalar in the same time!
by gmpassos (Priest) on May 10, 2003 at 05:40 UTC
    I don't use Symbol::gensym anymore! Please, test and take a look in the module.

    I still use GLOB, where it's cleanned with the object! Note that in Perl much things in your objects are GLOBAL, or have external access. (For example, when you use a IO::Handle, and any module that use it, like IO::File, you have a global GLOB object).

    But any global thing in OO is wrong, I know. But for now is that, with GLOB! Looking for better ways...

    Graciliano M. P.
    "The creativity is the expression of the liberty".

      How about posting the code here instead?

      Eh - I just created Lexical::Typeglob. For the moment it exists on my web site at http://www.greentechnologist.org/downloads/perl/ and it'll go on CPAN soon-ish.

      Added: You know what? I'm a moron - Symbol already does this and the whole reaping issue is moot.

        Cool! ;-P

        As I said in CB. I have found another way to save the different data types without GLOB! ;-P

        Now I'm using just a anonymous hash blessed. I have created a package for a Saver object of the data, where you have $saver->hash and $saver->set_hash...

        How you made the Lexical::Typeglob? It works for multiple objects? I say that because I was trying to use local(*FOO), but doesn't work when you have more than 1 object!

        Update: I have extended the multi type for CODE and GLOB, soo you can make:

        my $multi = Object::MultiType->new( code => sub{ print "CODE!\n" } , glob => \*STDOUT , ) ; &$multi(args) print $multi "Hello!" ;

        Graciliano M. P.
        "The creativity is the expression of the liberty".

        I just updated Lexical::Typeglob to 0.02. The *{lexglob()}{NAME} expression used to return undef, now it returns "". Similarly, *{lexglob()}{PACKAGE} used to cause perl to dereference a null pointer, now it just returns "". This probably isn't a serious issue since I don't think fetching PACKAGE is high on many lists for features.