> personally, [$ uses $] is quite enough for me.
>
> a few people seem to expect the [$ uses '../*' $] behaviour when they
> hear talk about search paths and selectively overriding things.
>
> but considering the performance impact, i think it would be best to
> document [$ uses '../*' $] and let people do it themselves.
I think I really like your idea. And I agree, [$ uses '../*' $] can be
optional, it's only one line. I have been playing around with the stuff
that Gerald came up with, and so far I have to do the following to get
the kind of inheritance that I'd like. If I'm doing stupid/unnecessary
stuff with Perl then that's because of my relative inexperience :-)
I'd like to confirm that the method I am using here (passing around a
reference to the 'subs' object in the req) is a sensible thing to do,
and that I am not being inefficient with memory or speed in any way. It
seems to me that I will now effectively be referencing all my (formerly
global) variables through a hash, which seems like it could introduce a
certain amount of additional overhead (because of the hash lookup every
time I refer to the variable). Will this appreciably affect performance?
I suppose it's necessary, so it's a moot point maybe.
Also, I store the package name in the hash, so that derived classes can
change their @ISA. I am not aware of how you might get the package name
of an object otherwise. Maybe there's a better way. Any comments
welcomed. Anyway, here it is:
base.html
[-
# Setup other packages
$req = shift;
Execute ({inputfile => 'subs.html', import => 0});
Execute ('subs.html#NEW', \$req->{subs});
# Example call
$req->{subs}->xxx;
# Do rest of html
Execute ('*');
-]
index.html
[-
$req = shift;
# Example call
$req->{subs}->xxx;
-]
subs.html
[$ sub NEW $]
[-
my $object = {};
bless $object, __PACKAGE__;
$object->{__PACKAGE__} = __PACKAGE__;
${$param[0]} = $object;
-]
[$ endsub $]
[! sub xxx{ print OUT "xxx"; } !]
foo/subs.html
[$ sub NEW $]
[-
Execute ({inputfile => '../subs.html', import => 0});
Execute ('../subs.html#NEW', \$object);
# Make sure we inherit from parent
@ISA = ($object->{__PACKAGE__});
# Keep object, but bless it into this package
bless $object, __PACKAGE__;
$object->{__PACKAGE__} = __PACKAGE__;
${$param[0]} = $object;
-]
[$ endsub $]
[!
sub xxx
{
my $self = shift;
print OUT "foo/xxx ";
# Example call to parent version
$self->SUPER::xxx (@_);
}
!]
This all seems to work just fine so far. It allows me to have real
inheritance without including everything in the same package (like I was
doing before). However as you can see it does involve a fair amount of
boilerplate code which might be better off living in Embperl.
Gus, I think that what I am doing here is pretty much functionally
equivalent to what you are suggesting with [$ uses $]. If I'm wrong then
please tell me how it differs. But your idea is much nicer, IMO.
Gerald, I don't know how much extra work this would be for you.
Obviously I don't want to rework all my websites to use the methods
which I give above, if you are going to add something like [$ uses $].
On the other hand, I do need to get on with stuff... what do you think?
I'm not trying to be pushy here, just wondering about timescale. If you
think it's really easy and a matter of a week or something like that
then I would hold off on rework (and the documentation/examples) so that
I can use the new version. If you think it would take longer or you are
very busy right now, then I would just go ahead and change over to doing
things the way I have it above.
Either way, thanks again, I like the way that EmbperlObject seems to be
headed.
-Neil
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]