Hey,

As some of you might have noticed, Dmitry worked on a Perl extension which allows PHP to run Perl scripts as well as instantiate Perl objects in PHP and use them.
The main problem with the extension is the fact that Perl functions behave differently according to their context (scalar/array) which doesn't exist in PHP. We thought of all sorts of ways to solve this problem but aren't sure what the best approach would be.
The current implementation uses scalar as default, and if you want an array, you can use perl_wantarray() and the next method call would return an array (the one after that would return scalar):


Example:

$x = new Perl("Test");
$y = $x->f(); // scalar context;
perl_wantarray();
$y = $x->f(); // array context;
$y = $x->f(); // scalar context;

This is obviously not very sexy. Other ideas could be passing an additional flag to the function call, possibly creating wrapper objects for the Perl objects which would decide on the type of method call. For example:
$x = new Perl("Test");
$y = new PerlScalar($x);
$z = $y->f(); // Scalar context
$w = new PerlArray($x);
$b = $w->f(); // Array context


Any ideas or suggestions? It would also be cool if people could mess around with it a bit and give us some feedback.
As it's in pecl it doesn't have to be finalized quickly but it would be nice to have something working for PHP 5's release (via pecl).


Thanks,

Andi

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to