Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Alain Williams
public function int doThing(string $foo) { return 1; } The above is the best (ie omit 'return' or 'returns'). This also is consistent with C and with the way that the manual is written, eg: http://www.php.net/manual/en/function.strlen.php The only argument is the relative ordering of t

[PHP-DEV] Re: Return type hinting patch

2008-04-25 Thread Edward Z. Yang
Sam Barrow wrote: > Attached is my return type hinting patch. [snip] I have a question independent of syntax/design-concerns: does this patch utilize typed returns to afford performance benefits to userland code that use it? -- Edward Z. YangGnuPG: 0x869C48DA HTML Purif

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Chris Stockton
Hello Sam, I think you misunderstand, let me retype for you. strlen('abstract protected function string dostuff()') < strlen('abstract protected function dostuff() return string') Making your argument on length void, also, maybe we should not base a language change decision on typing extra chara

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
I don't know, maybe it does work. But either way I'm not introducing a new keyword, I changed the patch to reuse the return keyword. Yes, long strings of keywords: abstract protected string function dostuff() On Fri, 2008-04-25 at 14:22 -0700, Chris Stockton wrote: > On Fri, Apr 25, 2008 at 12:2

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Michal Dziemianko
Hello everybody, I am new here (just reading for last couple of days), so firstly nice to meet you:) This discussion seems quite interesting for me and it would be nice if I can join... Sam Barrow napisal: im not sure the following has been explicitly proposed, but how about omitting the '

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Chris Stockton
On Fri, Apr 25, 2008 at 12:25 PM, Sam Barrow <[EMAIL PROTECTED]> wrote: > On Fri, 2008-04-25 at 13:24 -0600, Nathan Nobbe wrote: > > On Fri, Apr 25, 2008 at 1:15 PM, Sam Barrow <[EMAIL PROTECTED]> wrote: > > On Fri, 2008-04-25 at 14:08 -0500, Jeremy Privett wrote: > > > Sam Barrow

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
On Fri, 2008-04-25 at 13:24 -0600, Nathan Nobbe wrote: > On Fri, Apr 25, 2008 at 1:15 PM, Sam Barrow <[EMAIL PROTECTED]> wrote: > On Fri, 2008-04-25 at 14:08 -0500, Jeremy Privett wrote: > > Sam Barrow wrote: > > > I figured it out, the syntax is now as follows: > >

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Nathan Nobbe
On Fri, Apr 25, 2008 at 1:15 PM, Sam Barrow <[EMAIL PROTECTED]> wrote: > On Fri, 2008-04-25 at 14:08 -0500, Jeremy Privett wrote: > > Sam Barrow wrote: > > > I figured it out, the syntax is now as follows: > > > > > > function a($b, $c) returns d { > > > } > > > > > > I'll post an update soon. > >

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
On Fri, 2008-04-25 at 14:08 -0500, Jeremy Privett wrote: > Sam Barrow wrote: > > I figured it out, the syntax is now as follows: > > > > function a($b, $c) returns d { > > } > > > > I'll post an update soon. > > > > > > > > That's certainly a non-intuitive syntax. How about we take a page out o

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Jeremy Privett
Sam Barrow wrote: I figured it out, the syntax is now as follows: function a($b, $c) returns d { } I'll post an update soon. That's certainly a non-intuitive syntax. How about we take a page out of the book of other C-style languages before trying to invent something else? I agree with

Re: [PHP-DEV] issues with classnames, staic class members and constants as variables

2008-04-25 Thread Nathan Nobbe
On Fri, Apr 25, 2008 at 12:52 PM, Etienne Kneuss <[EMAIL PROTECTED]> wrote: > Sure: > > as I said earlier, it was proposed to be included already in 5.2.4, but > some people > objected as it represented "too much of a language change" which should not > happen > in minor release. So even though th

Re: [PHP-DEV] issues with classnames, staic class members and constants as variables

2008-04-25 Thread Etienne Kneuss
Sure: as I said earlier, it was proposed to be included already in 5.2.4, but some people objected as it represented "too much of a language change" which should not happen in minor release. So even though the patch impact was minimal, it was postponed and thus only committed in the 5_3 branch. R

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
I figured it out, the syntax is now as follows: function a($b, $c) returns d { } I'll post an update soon. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Stanislav Malyshev
Hi! Why note the following (which would be more C like): function return int a($arg1, $arg2) { } In C I am familiar with "return" keyword is never used in function definition. -- Stanislav Malyshev, Zend Software Architect [EMAIL PROTECTED] http://www.zend.com/ (408)253-88

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
> Why note the following (which would be more C like): > > function return int a($arg1, $arg2) { > } > > It gets a little long when you're using classes abstract protected function return int dostuff() { } vs abstract protected function dostuff() return int { } -- PHP Inter

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Alain Williams
On Fri, Apr 25, 2008 at 02:16:02PM -0400, Sam Barrow wrote: > > Can anyone help me with this? > > Here is the current function declaration rule: > T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING > optional_function_return_type { zend_do_begin_function_declaration(&$1, > &$

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
On Fri, 2008-04-25 at 10:06 -0700, Stanislav Malyshev wrote: > I notice it introduces new keyword - > returns. Is it necessary? Each new keyword means broken code. > I have adapted the patch to reuse the "return" keyword. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
Can anyone help me with this? Here is the current function declaration rule: T_FUNCTION { $1.u.opline_num = CG(zend_lineno); } is_reference T_STRING optional_function_return_type { zend_do_begin_function_declaration(&$1, &$4, 0, $3.op_type, NULL, &$5 TSRMLS_CC); } '(' parameter_list ')' '{' inner

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
On Fri, 2008-04-25 at 10:06 -0700, Stanislav Malyshev wrote: > Hi! > > In general, it'd be very nice to have some definition of the proposed > feature beyond the patch. It would probably answer some of my questions > that follow :) > > > parameters and return values. Objects with __toString met

Re: [PHP-DEV] Return type hinting patch

2008-04-25 Thread Stanislav Malyshev
Hi! In general, it'd be very nice to have some definition of the proposed feature beyond the patch. It would probably answer some of my questions that follow :) parameters and return values. Objects with __toString methods are allowed to pass for scalar and string type hints. What about ob

Re: [PHP-DEV] issues with classnames, staic class members and constants as variables

2008-04-25 Thread Nathan Nobbe
On Fri, Apr 25, 2008 at 10:44 AM, Etienne Kneuss <[EMAIL PROTECTED]> wrote: > Hello, > > Are you using a custom and outdated build of 5.2.4 ? > > $classname::$member was introduced in php5.2.4 but removed > before the actual release, and is now only present as of PHP5.3. > thanks for your reply.

Re: [PHP-DEV] issues with classnames, staic class members and constants as variables

2008-04-25 Thread Etienne Kneuss
Hello, Are you using a custom and outdated build of 5.2.4 ? $classname::$member was introduced in php5.2.4 but removed before the actual release, and is now only present as of PHP5.3. Regards On Fri, Apr 25, 2008 at 5:53 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote: > hello all, > > this is my m

[PHP-DEV] issues with classnames, staic class members and constants as variables

2008-04-25 Thread Nathan Nobbe
hello all, this is my maiden voyage on the internals list. recently i have discovered functionality that existed in php-5.2.4 that missing in php-5.2.5 and also php-5.2.6_rc3. i have posted to the php-general list and to the php-qa list and not received any sort of feedback about this discovery.

Re: [PHP-DEV] [PATCH] More array filling optimizations

2008-04-25 Thread Dmitry Stogov
Hi Matt, I like the idea (especially ZEND_INIT_ARRAY optimization) and from the first look patch seems proper. I'll need to look into it more careful before commit (probably on next week). Thanks. Dmitry. Matt Wilmas wrote: Hi all, Expanding on the idea of passing a size other than 0 to ze

[PHP-DEV] Return type hinting patch

2008-04-25 Thread Sam Barrow
Attached is my return type hinting patch. It allows type hinting for parameters and return values. Int, float, bool, string, num, scalar, resource, object, array, and class names are supported for both parameters and return values. Objects with __toString methods are allowed to pass for scalar and

Re: [PHP-DEV] [PATCH] More array filling optimizations

2008-04-25 Thread Matt Wilmas
Hi Andrey, - Original Message - From: "Andrey Hristov" Sent: Friday, April 25, 2008 > Hi, > [...] > heh, this optimisitations was one of the pluses mysqlnd had over > mysqli/libmysql. I am using the following macro: > > #if PHP_MAJOR_VERSION < 6 > #define mysqlnd_array_init(arg, field_c

Re: [PHP-DEV] [PATCH] More array filling optimizations

2008-04-25 Thread Andrey Hristov
Hi, Matt Wilmas wrote: Hi all, Expanding on the idea of passing a size other than 0 to zend_hash_init(), when possible, which was done awhile ago in a few areas (to save resize/rehash operations), I finally added an "array_init_size()" that can be used instead of array_init(), likewise, when a

[PHP-DEV] [PATCH] More array filling optimizations

2008-04-25 Thread Matt Wilmas
Hi all, Expanding on the idea of passing a size other than 0 to zend_hash_init(), when possible, which was done awhile ago in a few areas (to save resize/rehash operations), I finally added an "array_init_size()" that can be used instead of array_init(), likewise, when a size is known. As an exam

[PHP-DEV] [PATCH] Lazy symbol table initialization

2008-04-25 Thread Dmitry Stogov
Hi, The proposed patch delays EG(active_symbol_table) initialization till it 's really needed. Most functions don't need EG(active_symbol_table) at all, as they use IS_CV variables and HashTable initialization and updating just waste of time. The patch doesn't break any PHPT tests, it gives