in reply to Re: Re: objects becoming unblessed?
in thread objects becoming unblessed?

Jand,

I did miss the transitions and I agree about the data structure; however, if transitions is used to populate the data structure, it's not populating it with Emitter objects, but anonymous hashes. The transition (no s) used to move through the data structure, will need to create the objects (either via an object constructor or an initial blessing of the anon hash into the Emitter class).

From the snippets provided, it appears the objects have not become unblessed but were never blessed in the first place.

-derby

  • Comment on Re: Re: Re: objects becoming unblessed?

Replies are listed 'Best First'.
Re: Re: Re: Re: objects becoming unblessed?
by jand (Friar) on Mar 17, 2003 at 18:05 UTC
    You are missing one level of indirection. The objects are the keys of the unblessed hash (except that objects can't be keys). Look at the code again:
    $self->{START} = Emitter->new(); $self->{FAIR} = Emitter->new(); $self->{LOADED} = Emitter->new(); ... $self->{START}->transitions( { $self->{FAIR} => 0.5, $self->{LOADED} => 0.5 } );
    It does create 3 objects and then tries to set up 2 transitions using the anonymous hash. But the last line will already turn the object references into strings. It works as if it had been:
    $self->{START}->transitions( { "Emitter=HASH(0x12345678)" => 0.5, "Emitter=HASH(0xABCDABCD)" => 0.5 } );
      Okay. Yep. Add this to my list of reasons of why methods differentiated by only a letter is bad. I mis-read transtion and transtions (even after you pointed it out) and wrongly assumed transition returns $self->{TRANSITIONS}.

      Thanks for the wake-up.

      -derby