omnibus has asked for the wisdom of the Perl Monks concerning the following question:
results in$next_emitter = $current_emitter->transition(); print $next_emitter->emit() . "\n";
Indeed,Can't locate object method "emit" via package "Emitter=HASH(0x1016c9c0)" (perhaps you forgot to load "Emitter=HASH(0x1016c9c0)"?) at HMM/ODCRollGenerator.pm line 100.
results in Emitter=HASH(0x1016c9c0) whereasref($an_emitter->transition());
gives Emitter as expected.ref($an_emitter)
Within an Emitter, the transition table is stored as a hash, with the other Emitter instances as the keys, and the transition probabilities as the values. i.e. the setter method looks like this:
and it might be called like this:sub transitions { my $self = shift; if (@_) { $self->{TRANSITIONS} = shift; &_build_prob_table($self); } return $self->{TRANSITIONS}; }
$self->{START} = Emitter->new(); $self->{FAIR} = Emitter->new(); $self->{LOADED} = Emitter->new(); ... $self->{START}->transitions( { $self->{FAIR} => 0.5, $self->{LOADED} => 0.5 } );
Now, I can make things work by re-blessing the reference returned by transition(), but this seems awfully kludgy, and I suspect there is a better way to do this. Besides, as I understand it, it's the underlying thingy, not the reference, that is blessed. Anyone know what's going on here? Is there some magic I need to add to the class to keep the blessing attached to objects?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: objects becoming unblessed?
by jand (Friar) on Mar 17, 2003 at 16:50 UTC | |
|
Re: objects becoming unblessed?
by dragonchild (Archbishop) on Mar 17, 2003 at 18:00 UTC | |
by omnibus (Scribe) on Mar 17, 2003 at 19:03 UTC | |
|
Re: objects becoming unblessed?
by derby (Abbot) on Mar 17, 2003 at 17:09 UTC | |
by jand (Friar) on Mar 17, 2003 at 17:42 UTC | |
by derby (Abbot) on Mar 17, 2003 at 17:56 UTC | |
by jand (Friar) on Mar 17, 2003 at 18:05 UTC | |
by derby (Abbot) on Mar 17, 2003 at 18:12 UTC |