perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Angus Lees <...@inodes.org>
Subject Re: Embperl Wishes and comments
Date Mon, 04 Aug 2003 11:05:50 GMT
At Sun, 3 Aug 2003 10:28:13 -0400, Kee Hinckley wrote:
> At 10:37 PM -0700 8/2/03, <ckassab@eplsite.org> wrote:
> >- Embperlobject is great but, is it posible to have for embperl 2
> >  the feature to call subs from other files without using embperl
> >  object? maybe it is good to avoid the file search used in
> >  embperlobject using the base file base.epl.
> 
> Just call Execute with the import option.

importing is one method, some others:

"import"  (for reference)

 [- Execute({inputfile => 'other.epl', import => 1});
    func(@args);
 -]

 other.epl:
 [! sub func {
      my @args = @_;
      ...
    }
 !]


"sub"

 [- Execute('other.epl#func', @args);
      # or the more verbose
    Execute({inputfile => 'other.epl', sub => 'func', param => @args});
 -]

 other.epl:
 [! sub func {
      my @args = @param;
      ...
    }
 !]


"object"

 [- $other = Execute({object => 'other.epl'});
    $other->func(@args);
 -]

 other.epl:
 [! sub func {
      my $self = shift;
      my @args = @_;
      ...
    }
 !]


"isa"  (only works with EmbperlObject as shown)

 [! Execute({isa => 'other.epl'}) !]
 [- $req = shift;
    $req->func(@args);
 -]

 other.epl:
 [! sub func {
      my $req = shift;
      my @args = @_;
      ...
    }
 !]


"EMBPERL_OBJECT_HANDLER_CLASS"  (only works with EmbperlObject)

 [- $req = shift;
    $req->func(@args);
 -]

 httpd.conf:
 PerlSetEnv EMBPERL_OBJECT_HANDLER_CLASS Other
  (drop "PerlSetEnv" for Embperl2)

 Other.pm: (somewhere in Perl search path (@INC))
 package Other;
 sub func {
   my $req = shift;
   my @args = @_;
   ...
 }
 1;


All with various different tradeoffs in ease-of-use, memory usage,
run-time cost, etc of course.

In all these cases (except the last), you should be able to use a
[$ sub func $] in place of [! sub func {} !], if your function is
going to produce HTML.

There'd be some other variants more similar to usual Perl importing
too, like Exporter/@EXPORT_OK, or importing an AUTOLOAD function that
lazily imports real functions as needed.

-- 
 - Gus

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message