Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-24 Thread Roman I
This sounds very similar to preconditions in Design by Contract. However, preconditions validate input to the method as a whole, while the proposed syntax only checks individual arguments one at a time. Thus the proposed syntax has rather significan limitations compared to real preconditions. For

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-21 Thread Richard Lynch
On Fri, July 10, 2009 10:50 am, Alban wrote: Le Fri, 10 Jul 2009 16:16:51 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 10:57:22AM -0400, Alban wrote: Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: And

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-21 Thread Richard Lynch
On Tue, July 21, 2009 11:22 am, Christian Schneider wrote: Richard Lynch wrote: I think anybody who is coding with strict/weak/contract type-enforcement/casting is going to understand try/catch/Exceptions... I'm not going to start an pro/contra Exceptions rant but *please* keep Exceptions

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-21 Thread Christian Schneider
Richard Lynch wrote: I think anybody who is coding with strict/weak/contract type-enforcement/casting is going to understand try/catch/Exceptions... I'm not going to start an pro/contra Exceptions rant but *please* keep Exceptions out of the core language itself, that's a line we should not

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Pierre Joye
hi, I'm still in favour of #2 (Ilia's patch) as I don't see a real benefit of a weak typing implementation, it defeats the main goal of this addition. I'm also still opposed to add such thing in 5.3.x. Cheers, On Thu, Jul 9, 2009 at 9:47 AM, Zeev Suraskiz...@zend.com wrote: 2.  Move forward

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Giovanni Giacobbi
On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...] For example, instead of: function addFive(int $x) { return $x + 5; } You would simply do: function addFive(is_numeric $x) { return $x + 5; } Since $x is guaranteed to be

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Ionut G. Stan
On 7/10/2009 13:23, Giovanni Giacobbi wrote: On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...] For example, instead of: function addFive(int $x) { return $x + 5; } You would simply do: function addFive(is_numeric $x) { return $x + 5;

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Lewis Wright
2009/7/10 Ionut G. Stan ionut.g.s...@gmail.com On 7/10/2009 13:23, Giovanni Giacobbi wrote: On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...] For example, instead of: function addFive(int $x) { return $x + 5; } You would simply do:

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alain Williams
On Fri, Jul 10, 2009 at 01:35:45PM +0300, Ionut G. Stan wrote: On 7/10/2009 13:23, Giovanni Giacobbi wrote: On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...] For example, instead of: function addFive(int $x) { return $x + 5; } You would

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Lewis Wright
2009/7/10 Alain Williams a...@phcomp.co.uk On Fri, Jul 10, 2009 at 01:35:45PM +0300, Ionut G. Stan wrote: On 7/10/2009 13:23, Giovanni Giacobbi wrote: On Fri, Jul 10, 2009 at 02:44:52AM +0200, troels knak-nielsen wrote: [...] For example, instead of: function addFive(int $x)

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Lukas Kahwe Smith
On 10.07.2009, at 13:20, Lewis Wright wrote: 3) function Foo(is_int($x)) { Function is_int is called, an error is raised if it returns false. But then you're complicating it to the point where it's no longer much more useful than just calling the is_numeric method in the function

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alban
Le Thu, 09 Jul 2009 21:11:31 +0200, Geoffrey Sneddon a écrit : On 9 Jul 2009, at 18:20, Lukas Kahwe Smith wrote: On 09.07.2009, at 10:39, Paul Biggar wrote: I think we can take Lukas's RFC and either change it or write something based on it for weak typing only. If people here find it

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alain Williams
On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: Hello all, I don't understand why you focus on Strict / Weak question. It is really about: * type checking and enforcement or * type casting and generation of an error if the value cannot be converted cleanly Both of these have a

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Jack Allnutt
Please let me state that this is the greatest idea I read since the type hinting discussion began (and the only one I personally like, as I find all the other proposals really disappointing). +1. This contract system seems to be the best by far. -- PHP Internals - PHP Runtime

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Josh Thompson
Lukas Kahwe Smith m...@pooteeweet.org wrote: On 10.07.2009, at 13:20, Lewis Wright wrote: 3) function Foo(is_int($x)) { Function is_int is called, an error is raised if it returns false. But then you're complicating it to the point where it's no longer much more useful

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Ryan Panning
Alban wrote: I don't understand why you focus on Strict / Weak question. For me it's very simple, it's not obligatory use Type Hiting. Developpers wants to write a weak code, they'll just have to not use Type Hiting and developpers wants wrote a stric code they'll have to use it. After,

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Giovanni Giacobbi
On Fri, Jul 10, 2009 at 01:40:47PM +0200, Lukas Kahwe Smith wrote: On 10.07.2009, at 13:20, Lewis Wright wrote: 3) function Foo(is_int($x)) { Function is_int is called, an error is raised if it returns false. But then you're complicating it to the point where it's no longer

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alain Williams
Just to add a little fuel to this fire, should we allow the specification of return type of functions, eg: function int Factorial(int $num) {...} What about things that return FALSE on error, eg fgets(), something like this: function (string, bool) fgets(resource $handle, int

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alban
Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: Hello all, I don't understand why you focus on Strict / Weak question. It is really about: * type checking and enforcement or * type casting and generation of an

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Richard Quadling
2009/7/10 Alain Williams a...@phcomp.co.uk: Just to add a little fuel to this fire, should we allow the specification of return type of functions, eg:        function int Factorial(int $num) {...} What about things that return FALSE on error, eg fgets(), something like this:        

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alain Williams
On Fri, Jul 10, 2009 at 10:57:22AM -0400, Alban wrote: Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: Hello all, I don't understand why you focus on Strict / Weak question. It is really about: * type

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Lukas Kahwe Smith
On 10.07.2009, at 17:16, Alain Williams a...@phcomp.co.uk wrote: On Fri, Jul 10, 2009 at 10:57:22AM -0400, Alban wrote: Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit And Exception is better than an Error because this give one chance to programmer for resolving the

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Zeev Suraski
At 10:42 10/07/2009, Pierre Joye wrote: hi, I'm still in favour of #2 (Ilia's patch) as I don't see a real benefit of a weak typing implementation, it defeats the main goal of this addition. I'm also still opposed to add such thing in 5.3.x. Can you elaborate on what is the main goal of this

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alban
Le Fri, 10 Jul 2009 16:16:51 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 10:57:22AM -0400, Alban wrote: Le Fri, 10 Jul 2009 14:23:24 +0100, Alain Williams a écrit : On Fri, Jul 10, 2009 at 08:45:55AM -0400, Alban wrote: Hello all, I don't understand why you focus on

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Alain Williams
On Fri, Jul 10, 2009 at 11:50:04AM -0400, Alban wrote: Le Fri, 10 Jul 2009 16:16:51 +0100, Alain Williams a écrit : The GET argument, yes, should be an integer, but it's possible is not ! In this, actually i always use this syntaxe : is_child(intval($_GET['age'])); or is_child( (int)

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Jack Allnutt
*You* do the above because you know that you should; (hopefully you do other checks as well). One of the things that we are doing is trying to help the naive/lazy programmer who doesn't bother - or thinks that javascript checking is enough :-( What we want to do is to generate an

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Stanislav Malyshev
Hi! According to Zeev's description of the behavior this would cause a fatal error, as $_GET['a'] cannot be converted to an integer value.. I like that, but I think we need to devise a mechanism that allows you to catch this error at runtime and write application logic around it... In the

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Stanislav Malyshev
Hi! right .. lets not forget the original goal (though it hasnt been perfectly defined) the idea was to move common validation code out of the function body to reduce code, increase readability and enable IDE's to be even smarter. I think while intent is good (avoiding repetitive code) the

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Stanislav Malyshev
Hi! This would be the perfect pairing. A library utilizing strict/enforced types would surely want to indicate explicitly the return type. To what use? PHP can't do static type checking, and for dynamic checking specifying the type is useless - it's zval that gets checked, not the

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-10 Thread Lukas Kahwe Smith
On 10.07.2009, at 19:58, Stanislav Malyshev wrote: Hi! right .. lets not forget the original goal (though it hasnt been perfectly defined) the idea was to move common validation code out of the function body to reduce code, increase readability and enable IDE's to be even smarter. I

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Paul Biggar
Hi Zeev, I've been keeping a very close eye, and have taken part in a good few discussions, including putting my own idea on the table. On Thu, Jul 9, 2009 at 8:47 AM, Zeev Suraskiz...@zend.com wrote: The options as I see them: 1.  Do nothing.  I think the vote established that this is not

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Zeev Suraski
At 11:39 09/07/2009, Paul Biggar wrote: I believe nearly all opinions voiced have wanted the current patch. Many more were in favour of strict typing only, but for the few dissenters, like myself, Ilia included casting semantics using (int) syntax. I think that many of the people who expressed

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Paul Biggar
On Thu, Jul 9, 2009 at 10:46 AM, Zeev Suraskiz...@zend.com wrote: I believe that if we had a 'clean' Weak typing RFC as well as a Strict typing RFC, each with its pros and cons - there would be very different results. The two approaches were never compared head-to-head, with the pros and cons

RE: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Dennis Haarbrink
-Oorspronkelijk bericht- Van: Zeev Suraski [mailto:z...@zend.com] Verzonden: donderdag 9 juli 2009 11:46 Aan: Paul Biggar CC: internals@lists.php.net Onderwerp: Re: [PHP-DEV] Type hinting - Request for Discussion At 11:39 09/07/2009, Paul Biggar wrote: I believe nearly all

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Paul Biggar
Hi Dennis, On Thu, Jul 9, 2009 at 11:49 AM, Dennis Haarbrinkden...@born05.nl wrote: The most important thing is that it is _optional_, you have the _choice_ to use it. Sorry to go a little bit off-topic, but this idea has been bandied around a lot over the last week, and I'd like to respond to

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Patrick ALLAERT
2009/7/9 Zeev Suraski z...@zend.com: Two other issues that we need to revisit: 1.  Agree on when it will be implemented - I think it's pretty clear it should not go to 5.3. What would be the impact including this feature (once it is *technically* fine for everybody) in 5.3 code with #ifdef's

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Lukas Kahwe Smith
On 09.07.2009, at 13:10, Patrick ALLAERT wrote: 2009/7/9 Zeev Suraski z...@zend.com: Two other issues that we need to revisit: 1. Agree on when it will be implemented - I think it's pretty clear it should not go to 5.3. What would be the impact including this feature (once it is

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Lukas Kahwe Smith
On 09.07.2009, at 12:49, Dennis Haarbrink wrote: I'm a framework developer and I have great interest in type hinting/ casting. I'm all for clarity and strictness, but it should definitely be a choice. PHP is known for its easy learning curve, that is one of its big powers and that should

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Paul Biggar
On Thu, Jul 9, 2009 at 1:33 PM, Dennis Haarbrinkden...@born05.nl wrote: I mean, libraries may have all kinds of quirks, you may not be satisfied with the supplied API or maybe even the entire philosophy behind it, but that shouldn't stop you from using it or is it? You must learn what these

RE: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Dennis Haarbrink
Hi Paul, -Oorspronkelijk bericht- Van: Paul Biggar [mailto:paul.big...@gmail.com] Verzonden: donderdag 9 juli 2009 13:03 Aan: Dennis Haarbrink CC: internals@lists.php.net Onderwerp: Re: [PHP-DEV] Type hinting - Request for Discussion Although the proposed checks are optional

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Christian Schneider
Zeev Suraski wrote: We need to go back to the fundamentals - and look for use cases where strict typing would be substantially superior to weak typing. I whole-heartedly agree. I can see some benefits of having weak typing (even though I'm not desperate for it) and think it would better fit PHP

RE: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Dennis Haarbrink
Lukas, -Oorspronkelijk bericht- Van: Lukas Kahwe Smith [mailto:m...@pooteeweet.org] Verzonden: donderdag 9 juli 2009 14:01 Aan: Dennis Haarbrink CC: internals@lists.php.net Onderwerp: Re: [PHP-DEV] Type hinting - Request for Discussion I think you misunderstood Zeev. He

RE: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Dennis Haarbrink
-Oorspronkelijk bericht- Van: Paul Biggar [mailto:paul.big...@gmail.com] Verzonden: donderdag 9 juli 2009 14:40 Aan: Dennis Haarbrink CC: internals@lists.php.net Onderwerp: Re: [PHP-DEV] Type hinting - Request for Discussion You must learn what these quirks are. Likewise, every

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Lukas Kahwe Smith
On 09.07.2009, at 10:39, Paul Biggar wrote: I think we can take Lukas's RFC and either change it or write something based on it for weak typing only. If people here find it useful I'll go ahead and do that. I believe people don't want this. I wrote a set of rules, Lukas wrote the RFC,

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Paul Biggar
On Thu, Jul 9, 2009 at 5:20 PM, Lukas Kahwe Smithm...@pooteeweet.org wrote: Actually, in terms of weak typing we are now at 4 supporters of the general idea: Paul B., Better make that 3 supporters. After seeing how complicated it was to explain the semantics of a sensible middle, I think the

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Stan Vassilev
I want to remind everyone that this discussion is inadvertently sabotaging the work/schedule of maintenance 5.3.x point releases, which we actually need, for the 5.3 branch get to a point where it's stable enough to be used in production. So, knowing this can go on forever, it's time to pick

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread troels knak-nielsen
Hi list. In advance, sorry for muddying the waters even further. Following the current discussion about typehints to primitives, I'm wondering if anyone have ever suggested to include some sort of user-land contract system, such as the one that exists in plt-scheme[1] Given the dynamic nature

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Stanislav Malyshev
Hi! Actually, in terms of weak typing we are now at 4 supporters of the general idea: Count me in, then :) -- Stanislav Malyshev, Zend Software Architect s...@zend.com http://www.zend.com/ (408)253-8829 MSN: s...@zend.com -- PHP Internals - PHP Runtime Development Mailing List To

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Geoffrey Sneddon
On 9 Jul 2009, at 18:20, Lukas Kahwe Smith wrote: On 09.07.2009, at 10:39, Paul Biggar wrote: I think we can take Lukas's RFC and either change it or write something based on it for weak typing only. If people here find it useful I'll go ahead and do that. I believe people don't want

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Guillaume Rossolini
Hi! I am a userland developer, so please take my advice with caution. I am not aware of the consequences of any of the implementations from an internals point of view. However, since the main question here seems to be strict against weak typing, or casting, I feel I should voice my opinion.

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Josh Thompson
troels knak-nielsen wrote: 1) It covers all the use cases for a type-based system (You can use `is_integer` as a contract, if you want that) 2) It's extensible in user-space, which means that it can be used to convey much more accurate information, relevant to the application needs. 3) It's

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread troels knak-nielsen
On Fri, Jul 10, 2009 at 2:28 AM, Josh Thompsonspam.goes.in.h...@gmail.com wrote: troels knak-nielsen wrote:  - How do you know if it is a contract or the current object type hint? The simplest solution would be to make one take precedence. You're not likely to have both a class and a function

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread Josh Thompson
troels knak-nielsen wrote: - How do you know if it is a contract or the current object type hint? The simplest solution would be to make one take precedence. You're not likely to have both a class and a function with the same name, and if you do, you kind of had it coming to you. For

Re: [PHP-DEV] Type hinting - Request for Discussion

2009-07-09 Thread John Coggeshall
All: I'm in favor of this so-called Weak typing Zeev has proposed as well, but I would like to see it become available in PHP before PHP 6. That doesn't mean it has to go into 5.3.x, but I don't see why there can't be a 5.4 that includes it. Personally, I think primitive typing has a much more