From: Vsevolod (S. I. <si...@cs...> - 2004-01-06 16:33:03
|
> > Okay, I've got a test script + classes that has this setup with strict > field checking and field autodiscovery. Sorry, no script was attached. :( > >> 1. My classes have a superclass. Let's call it MyObject. So I inherit >> MyBooks from SPOPS_Books and MyObject. I have to double-dispatch the >> new() method, but I can live with it. > > This might be a problem. How are you dispatching new()? Nothing fancy - in MyObject: sub new { my ($proto) = shift; my %args = %{$_[0]}; my $self = $proto->SUPER::new(@_); $self->_new(\%args); return $self; } MyObject inherits from ProtoObject, which is a parent also to non-SPOPS classes. In ProtoObject, _new() calls $self->new(), and everybody's happy. Since only one ugly method was introduced, this is not a big deal. > As an aside: you can also use the kludge of storing it in a field named > 'tmp_foo' -- anything that starts with 'tmp_' is ignored by the tie > implementation. (Did I mention that I hate tie? :-) Okay, I'll try to work with this. > One thing I noticed is that you have a 'require SPOPS_Job' in Job and a > corresponding one for Task. Get rid of that, you don't need it and might > be causing the problem: Thanks - that helped my script to compile! However, when I added another line: Job->fetch(1) I got this: Can't locate package SPOPS_Job for @Job::ISA at script.pl line 5. Can't locate package SPOPS_Job for @Job::ISA at script.pl line 6. Can't locate package SPOPS_Job for @Job::ISA at script.pl line 6. Can't locate object method "fetch" via package "Job" at script.pl line 6. Simon -- Simon (Vsevolod ILyushchenko) si...@cs... http://www.simonf.com America's business leaders simply don't want to think about complex technology issues - they want to think about golf. Microsoft promises them that. Andrew Grygus, www.aaxnet.com |