Mailing List Archive

use and Execute differences
Hello,

Searched through the documentation and mailing lists but could not find the
exact information.
What are the most important differences between using normal perl module
with:

use Package::Module

$obj = Package::Module->new();

or using

$obj = Execute({object => 'package/module.pl', syntax => 'Perl'});
$obj->new();

When we think about reusability then the first strategy (with use) would be
better since we can later use these modules with other systems.
Also I think memory usage would be more efficient since use only loads
modules when necessary.

But would there be any cases where the latter (Execute) would be more
preferable? And how about its memory usage?

Using Embperl 2.2.0.

With kind regards,
Villu Roogna
RE: use and Execute differences [ In reply to ]
Hi,

>
> Searched through the documentation and mailing lists but
> could not find the exact information.
> What are the most important differences between using normal
> perl module with:
>
> use Package::Module
>
> $obj = Package::Module->new();
>
> or using
>
> $obj = Execute({object => 'package/module.pl', syntax =>
> 'Perl'}); $obj->new();
>
> When we think about reusability then the first strategy (with
> use) would be better since we can later use these modules
> with other systems.
> Also I think memory usage would be more efficient since use
> only loads modules when necessary.
>
> But would there be any cases where the latter (Execute) would
> be more preferable? And how about its memory usage?
>

Execute does an reload when the source changes and it seaches the same
way as other pages (this is interesting for use with Embperl::Object).
Execute also only loads the module once, like use does. Execute put
every file in a different namespace.

When using with Embperl::Object, you can have the same file in different
directories and depending on the URL a differnt file is called.

Gerald




** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: use and Execute differences [ In reply to ]
Understood and yes Embperl::Object logic is very useful indeed.

Villu