> 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.
>

You are right, it introduces some overhead, but I don't think it's too much.
That's the way class data is handled in OO Perl. It's a general drawback of
OO technologie, that it introduce some overhead, but it gives you other
benefits...

>
> 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.

ref ($object) returns the package name of an object

>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});

You could move the import in a [! !] block, so it will only be executed once
at compile time

> Execute ('subs.html#NEW', \$req->{subs});
>
> # Example call
> $req->{subs}->xxx;
>

If you need this reference often, I would make a copy in a global and use
that for the method call and the $req->{subs} just for passing around to
other modules. So everything that has to be shared lives in $req->{xxx} and
any local data uses normal Perl variables.

> # 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.
>

Yes, I like to put it into Embperl.

>
> 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.
>

Neil, it isn't so much work to implement this features (some hours, the main
work on such features is to build the tests) and I would like to implement
them soon, because I see they are really usefull. Unfortunately we have
chrismas in front of our door and I will be on holiday until the beginning
of januray (without any laptop :-) (that's of course only unfortunately for
you and not for me ;-). I have recently spend much time with Embperl 2.0 and
of course have to do "some" other work. I try to implement it at the
beginning of january, but I can't promise you anything.

Sorry, if I can't do it quicker, I also would like to do so

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to