Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8292 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93173 invoked by uid 1010); 1 Mar 2004 22:10:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 93139 invoked from network); 1 Mar 2004 22:10:58 -0000 Received: from unknown (HELO mail.zend.com) (192.117.235.230) by pb1.pair.com with SMTP; 1 Mar 2004 22:10:58 -0000 Received: (qmail 17837 invoked from network); 1 Mar 2004 22:10:52 -0000 Received: from guardian.zend.office (HELO AndiNotebook.zend.com) (10.1.1.4) by mail.zend.com with SMTP; 1 Mar 2004 22:10:52 -0000 Message-ID: <5.1.0.14.2.20040302000350.0272fc70@127.0.0.1> X-Sender: andi@127.0.0.1 X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 02 Mar 2004 00:10:51 +0200 To: internals@lists.php.net Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Perl extension From: andi@zend.com (Andi Gutmans) 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