Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Dmitry Stogov
On Thu, Feb 5, 2015 at 9:50 PM, Andrea Faulds a...@ajf.me wrote: Hi, On 5 Feb 2015, at 06:52, Dmitry Stogov dmi...@zend.com wrote: I completely agree. Strict typing doesn't fit into PHP. It was already told thousand times. Seems to work rather well in practice, so long as it’s

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Pierre Joye
On Thu, Feb 5, 2015 at 2:22 PM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! True, but obviously, us who want strict typehints want to be able to do this: Obviously, but it doesn't mean whole language should be changed to serve one use case, especially the one that goes contrary to what

RE: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread François Laupretre
De : Stanislav Malyshev [mailto:smalys...@gmail.com] Adding another concept, not changing the existing ones. And really, it's just simplifying what is already present via is_typename() runtime checks, making our lives a little bit easier. There's a very big difference between allowing to

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Stanislav Malyshev
Hi! However I feel like the fact that it only affects your app (even if you use a library relying on strictness) if you want to is not clear for everyone replying here. Is this point clear for you? I was addressing the idea that every scalar type mention should be strict. If it is a choice, I

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Andrea Faulds
Hi, On 5 Feb 2015, at 19:15, Dmitry Stogov dmi...@zend.com wrote: works and fits are different. Fair point. Strict type hinting may help catching problems only at run-time. In PHP you almost never can do something ahead of time, because of run-time binding. You may only guess,

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Andrey Andreev
Hi, On Thu, Feb 5, 2015 at 9:22 AM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! True, but obviously, us who want strict typehints want to be able to do this: Obviously, but it doesn't mean whole language should be changed to serve one use case, especially the one that goes contrary to

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Pavel Kouřil
On Thu, Feb 5, 2015 at 9:59 AM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! However I feel like the fact that it only affects your app (even if you use a library relying on strictness) if you want to is not clear for everyone replying here. Is this point clear for you? I was

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Andrea Faulds
Hi, On 5 Feb 2015, at 06:52, Dmitry Stogov dmi...@zend.com wrote: I completely agree. Strict typing doesn't fit into PHP. It was already told thousand times. Seems to work rather well in practice, so long as it’s optional. Also, the only really useful case for strict typing is the ability

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-05 Thread Andrea Faulds
Hi François, On 5 Feb 2015, at 08:58, François Laupretre franc...@tekwire.net wrote: +1. Checking IS_type at the C level after implicit conversions and checking this at the PHP level are very different. IMHO, the key point is the concept of 'type'. Strict typing considers a one-to-one

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Yasuo Ohgaki
Hi Dmitry, On Wed, Feb 4, 2015 at 4:25 PM, Dmitry Stogov dmi...@zend.com wrote: The idea of that RFC was an ability to have zero-cost assert(). DbC is a much more bigger feature, it is interesting, but requires significant work. Type check and DbC integration would require significant

RE: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread François Laupretre
De : Dmitry Stogov [mailto:dmi...@zend.com] The idea of that RFC was an ability to have zero-cost assert(). DbC is a much more bigger feature, it is interesting, but requires significant work. I agree. My suggestion was just to consider assertions as part of this future work (by using 'dbc'

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dmitry Stogov
I mean a lot of work designing this concept properly, writing RFC, discussing, coming to consensus, etc The implementation itself may be quite simple. If anyone can take care about design, I may help with implementation. Thanks. Dmitry. On Wed, Feb 4, 2015 at 12:02 PM, Yasuo Ohgaki

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Sebastian Bergmann
Am 04.02.2015 um 10:25 schrieb Dmitry Stogov: Do you like the proposal with declare() switch? No, I do not like that. We are talking about adding support for scalars (string, integer, ...) to the list of optional type declarations already supported (array, callable, interface name, class

AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Robert Stoll
-Ursprüngliche Nachricht- Von: Dmitry Stogov [mailto:dmi...@zend.com] Gesendet: Mittwoch, 4. Februar 2015 10:26 An: Sebastian Bergmann Cc: PHP Internals Betreff: Re: [PHP-DEV] What do we need strict scalar type hints for? hi Sebastian, Do you like the proposal with declare

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dmitry Stogov
hi Sebastian, Do you like the proposal with declare() switch? Don't you afraid of sin(1) break? (it's just an example, telling how many things may be broken). Thanks. Dmitry. On Wed, Feb 4, 2015 at 10:30 AM, Sebastian Bergmann sebast...@php.net wrote: Am 04.02.2015 um 08:25 schrieb Dmitry

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Yasuo Ohgaki
Hi Dmitry, On Wed, Feb 4, 2015 at 6:22 PM, Dmitry Stogov dmi...@zend.com wrote: I mean a lot of work designing this concept properly, writing RFC, discussing, coming to consensus, etc The implementation itself may be quite simple. If anyone can take care about design, I may help with

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrea Faulds
Hi Robert, On 4 Feb 2015, at 09:38, Robert Stoll p...@tutteli.ch wrote: Personally I am not in favour of the declare approach because the user will need to switch between strict context and non-strict context which will be quite challenging, anti-efficient (in terms of productivity) and

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrea Faulds
Hi again, On 4 Feb 2015, at 11:15, Andrey Andreev n...@devilix.net wrote: On Wed, Feb 4, 2015 at 1:02 PM, Florian Margaine flor...@margaine.com wrote: Hi Leigh, Le 4 févr. 2015 11:50, Leigh lei...@gmail.com a écrit : What was wrong with: function x(int $y, string $z) { // strict

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrey Andreev
Hi Andrea, On Wed, Feb 4, 2015 at 8:21 PM, Andrea Faulds a...@ajf.me wrote: Hi again, On 4 Feb 2015, at 11:15, Andrey Andreev n...@devilix.net wrote: On Wed, Feb 4, 2015 at 1:02 PM, Florian Margaine flor...@margaine.com wrote: Hi Leigh, Le 4 févr. 2015 11:50, Leigh lei...@gmail.com a

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrea Faulds
Hi, On 4 Feb 2015, at 18:41, Andrey Andreev n...@devilix.net wrote: I didn't want to turn this thread into a re-iteration of the RFC discussion one. I'm just completely surprised how relentlessly all suggestions about two syntaxes have been waved off by a callee vs caller argument like

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread S.A.N
We all external data convert to native PHP types. The database we use option MYSQLI_OPT_INT_AND_FLOAT_NATIVE. HTTP inputs are validated and converted to native PHP types. In Redis data are stored as serialize string. Strong typing I like. -- PHP Internals - PHP Runtime Development Mailing List

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Leigh
On 4 February 2015 at 11:02, Florian Margaine flor...@margaine.com wrote: Because it is then the callee who decides, not the caller, whether or not he wants strict typing. And that is the way it should be. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit:

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Stanislav Malyshev
Hi! We are talking about adding support for scalars (string, integer, ...) to the list of optional type declarations already supported (array, callable, interface name, class name) by PHP. When a developer chooses to use a scalar type in the signature of a function or method then it

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrey Andreev
Hi, On Thu, Feb 5, 2015 at 2:06 AM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! We are talking about adding support for scalars (string, integer, ...) to the list of optional type declarations already supported (array, callable, interface name, class name) by PHP. When a developer

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Stanislav Malyshev
Hi! Adding another concept, not changing the existing ones. And really, it's just simplifying what is already present via is_typename() runtime checks, making our lives a little bit easier. There's a very big difference between allowing to check types (and then do whatever you wish) and

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Pierre Joye
On Feb 5, 2015 7:58 AM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! Adding another concept, not changing the existing ones. And really, it's just simplifying what is already present via is_typename() runtime checks, making our lives a little bit easier. There's a very big

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrey Andreev
Hi, On Thu, Feb 5, 2015 at 2:58 AM, Stanislav Malyshev smalys...@gmail.com wrote: Hi! Adding another concept, not changing the existing ones. And really, it's just simplifying what is already present via is_typename() runtime checks, making our lives a little bit easier. There's a very big

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Stanislav Malyshev
Hi! True, but obviously, us who want strict typehints want to be able to do this: Obviously, but it doesn't mean whole language should be changed to serve one use case, especially the one that goes contrary to what happened in PHP for decades. -- Stas Malyshev smalys...@gmail.com -- PHP

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dmitry Stogov
I completely agree. Strict typing doesn't fit into PHP. It was already told thousand times. Check the second requirement in RFC template https://wiki.php.net/rfc/template Also, the only really useful case for strict typing is the ability to catch mistakes in user apps. However, this ability is

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dmitry Stogov
If you write draft RFC, and I like it, I'll take care about implementation. Most probably implementation may cause some changes in design. For now, I may just guess, how it should look like from user perspective. Thanks. Dmitry. On Wed, Feb 4, 2015 at 12:34 PM, Yasuo Ohgaki yohg...@ohgaki.net

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Andrey Andreev
Hi, On Wed, Feb 4, 2015 at 1:02 PM, Florian Margaine flor...@margaine.com wrote: Hi Leigh, Le 4 févr. 2015 11:50, Leigh lei...@gmail.com a écrit : What was wrong with: function x(int $y, string $z) { // strict function x((int) $y, (string) $z) { // casting This was the best suggestion

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dmitry Stogov
This won't fit into loosely-typed PHP, and will lead to writing - sin((float)$x). We have this in PHP sources :) (in C) Thanks. Dmitry. On Wed, Feb 4, 2015 at 12:31 PM, Sebastian Bergmann sebast...@php.net wrote: Am 04.02.2015 um 10:25 schrieb Dmitry Stogov: Do you like the proposal with

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Yasuo Ohgaki
Hi Dmitry, On Wed, Feb 4, 2015 at 7:19 PM, Dmitry Stogov dmi...@zend.com wrote: If you write draft RFC, and I like it, I'll take care about implementation. Most probably implementation may cause some changes in design. For now, I may just guess, how it should look like from user perspective.

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Florian Margaine
Hi Leigh, Le 4 févr. 2015 11:50, Leigh lei...@gmail.com a écrit : What was wrong with: function x(int $y, string $z) { // strict function x((int) $y, (string) $z) { // casting This was the best suggestion I've seen that covers the requirements of both camps, and is still very clear how

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Pierre Joye
On Feb 4, 2015 6:15 PM, Andrey Andreev n...@devilix.net wrote: Hi, On Wed, Feb 4, 2015 at 1:02 PM, Florian Margaine flor...@margaine.com wrote: Hi Leigh, Le 4 févr. 2015 11:50, Leigh lei...@gmail.com a écrit : What was wrong with: function x(int $y, string $z) { // strict

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Leigh
What was wrong with: function x(int $y, string $z) { // strict function x((int) $y, (string) $z) { // casting This was the best suggestion I've seen that covers the requirements of both camps, and is still very clear how data is going to be handled. Authors who want their APIs to adhered to

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Dan Ackroyd
On 4 February 2015 at 10:13, Dmitry Stogov dmi...@zend.com wrote: This won't fit into loosely-typed PHP, and will lead to writing - sin((float)$x). Hi Dmitry, I think what people miss is that the place where the conversion from an unknown type to an int takes place, is also the place where you

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-04 Thread Sebastian Bergmann
On 02/04/2015 04:32 PM, Dan Ackroyd wrote: btw For your exact example `sin((float)$x).` this is actually a case where another scalar type of 'number' which is satisfiable by either a float or an int would be useful, but that's definitely a step too far before we have any scalar type hints.

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Dmitry Stogov
On Tue, Feb 3, 2015 at 7:14 PM, Andrea Faulds a...@ajf.me wrote: Hi Dmitry, On 3 Feb 2015, at 04:07, Dmitry Stogov dmi...@zend.com wrote: I have similar opinion. Strict typing looks foreign for PHP. It is in a way, yes. PHP has traditionally been “weakly-typed” everywhere. That being

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Dmitry Stogov
Hi Yasuo, You probably talk about https://wiki.php.net/rfc/expectations I wasn't the author of idea, I just helped with thoughts and implantation. I think it may be useful for PHP7. Thanks. Dmitry. On Tue, Feb 3, 2015 at 11:12 PM, Yasuo Ohgaki yohg...@ohgaki.net wrote: Hi Dmitry, On

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Yasuo Ohgaki
Hi Dmitry, On Wed, Feb 4, 2015 at 2:36 PM, Dmitry Stogov dmi...@zend.com wrote: You probably talk about https://wiki.php.net/rfc/expectations I wasn't the author of idea, I just helped with thoughts and implantation. I think it may be useful for PHP7. Thank you for the info. It would be

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Sebastian Bergmann
Am 04.02.2015 um 08:25 schrieb Dmitry Stogov: The idea of that RFC was an ability to have zero-cost assert(). But an assert() is still in the body of a function or method and not part of its signature. That is what I want scalar type declarations for. -- PHP Internals - PHP Runtime

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Dmitry Stogov
The idea of that RFC was an ability to have zero-cost assert(). DbC is a much more bigger feature, it is interesting, but requires significant work. Thanks. Dmitry. On Wed, Feb 4, 2015 at 10:11 AM, François Laupretre franc...@tekwire.net wrote: De : Dmitry Stogov [mailto:dmi...@zend.com]

RE: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread François Laupretre
De : Dmitry Stogov [mailto:dmi...@zend.com] Hi Yasuo, You probably talk about https://wiki.php.net/rfc/expectations I wasn't the author of idea, I just helped with thoughts and implantation. I think it may be useful for PHP7. In accordance with Yasuo's suggestions, couldn't we consider

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Andrea Faulds
Hi Sven, On 3 Feb 2015, at 19:07, Sven Drieling s...@sven-drieling.de wrote: What about scalar type declaration in userland? It’s one of many suggestions. I really, really don’t think it’s a good idea. Rather than having two models (as the RFC suggests), we’d have n models, where n is the

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Andrea Faulds
Hi Dmitry, On 3 Feb 2015, at 04:07, Dmitry Stogov dmi...@zend.com wrote: I have similar opinion. Strict typing looks foreign for PHP. It is in a way, yes. PHP has traditionally been “weakly-typed” everywhere. That being said, we’re not always weakly-typed (there are strict type checks in

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Sven Drieling
Am Mon, 02 Feb 2015 23:38:21 +0100 schrieb Christoph Becker cmbecke...@gmx.de: Hallo, addVat(-1); Well, my point was that even a strict type system doesn't necessarilly catch all erroneous/undesired arguments. Even if addVat() properly handles negative numbers, and maybe even zeroes,

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Yasuo Ohgaki
Hi Dmitry, On Mon, Feb 2, 2015 at 6:12 PM, Dmitry Stogov dmi...@zend.com wrote: could you please write down few use cases, when strict scalar type hints are really useful. I'm not opposing to have scalar type hints, but assertion can do better job for it. I think you have proposed assert()

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Yasuo Ohgaki
Hi all, On Wed, Feb 4, 2015 at 5:23 AM, Thomas Bley ma...@thomasbley.de wrote: function addVat($amount) { validateAmount($amount); return round($amount*1.19, 2); } function validateAmount($amount) { if (!is_int($amount) !is_float($amount)) { throw new

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-03 Thread Thomas Bley
I would prefer: function addVat($amount) { validateAmount($amount); return round($amount*1.19, 2); } function validateAmount($amount) { if (!is_int($amount) !is_float($amount)) { throw new InvalidArgumentException('Argument amount must be of the type int|float, '.gettype($amount).'

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Andrea Faulds
Hi Dmitry, On 2 Feb 2015, at 20:43, Dmitry Stogov dmi...@zend.com wrote: I don't think we will implement strict semantic for operators. It's not going to be PHP anymore $s = (string)$a . (string)$b; There’s no need either: operators always produce a specific type (or one of a set of

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Christoph Becker
Thomas Bley wrote: Here is a typical billing example which uses exceptions: ?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); addVat('apples'); function addVat($amount) { if (!is_int($amount) !is_float($amount)) { throw new

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Lester Caine
On 02/02/15 21:17, Christoph Becker wrote: Instead of multiple strict scalar hints (e.g. function addVat(int|float $amount){...}), I would prefer to have numeric as strict type: function addVat(numeric $amount){...} Have you considered addVat(-1); Also addVat(1.235); which will be

AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Robert Stoll
-Ursprüngliche Nachricht- Von: Dmitry Stogov [mailto:dmi...@zend.com] Gesendet: Montag, 2. Februar 2015 20:14 An: Robert Stoll Cc: PHP Internals; Andrea Faulds; Nikita Popov Betreff: Re: [PHP-DEV] What do we need strict scalar type hints for? On Mon, Feb 2, 2015 at 9:41 PM, Robert

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Arvids Godjuks
2015-02-02 11:12 GMT+02:00 Dmitry Stogov dmi...@zend.com: hi, could you please write down few use cases, when strict scalar type hints are really useful. Thanks. Dmitry. Hello Dmitry, At the moment, being a user-land dev for a little bit more than 10 years, I just don't see the usage for

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Thomas Bley
Here is a typical billing example which uses exceptions: ?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); addVat('apples'); function addVat($amount) { if (!is_int($amount) !is_float($amount)) { throw new InvalidArgumentException('Argument 1 passed to '.__FUNCTION__.'

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Lester Caine
On 02/02/15 09:12, Dmitry Stogov wrote: could you please write down few use cases, when strict scalar type hints are really useful. Do we NEED strict scalar type control ... No Are there situations where strict scalar type control may be useful ...Yes Can a library be built ONLY using strict

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Andrey Andreev
Hi, On Mon, Feb 2, 2015 at 11:03 PM, Thomas Bley ma...@thomasbley.de wrote: Here is a typical billing example which uses exceptions: ?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); addVat('apples'); function addVat($amount) { if (!is_int($amount)

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Thomas Bley
Yes, we currently have negative values for invoices and positive for vouchers ... Christoph Becker wrote on 02.02.2015 22:17: Thomas Bley wrote: Here is a typical billing example which uses exceptions: ?php ini_set('error_reporting', E_ALL); ini_set('display_errors', 1);

Re: AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
Betreff: [PHP-DEV] What do we need strict scalar type hints for? hi, could you please write down few use cases, when strict scalar type hints are really useful. Thanks. Dmitry. I think strict types are beneficial in all those places where you would put

Re: AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Lester Caine
On 02/02/15 20:15, Robert Stoll wrote: Nobody would stop you from implementing a utility class Money or likewise and providing a better error message instead of using int if PHP would be strict only (what is not proposed in the RFC anyway). You could also just omit the type hint, it is

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Christoph Becker
Thomas Bley wrote: Yes, we currently have negative values for invoices and positive for vouchers ... Christoph Becker wrote on 02.02.2015 22:17: Thomas Bley wrote: Here is a typical billing example which uses exceptions: ?php ini_set('error_reporting', E_ALL);

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Andrea Faulds
Hi again, On 2 Feb 2015, at 23:34, Christoph Becker cmbecke...@gmx.de wrote: Indeed, code is read far more often than it's written (hopefully :)), but still it might be annoying for many PHP programmers to write these explicit manual conversions in the first place.[2] Well, they only have

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Christoph Becker
Hi Andrea, Andrea Faulds wrote: Hi Christoph, On 2 Feb 2015, at 22:38, Christoph Becker cmbecke...@gmx.de wrote: And frankly, I don't see what's wrong with a weak type hint in this case: function addVat(float $amount) {...} You're returning a float, anyway. Given you’re dealing

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Andrea Faulds
Hi Christoph, On 2 Feb 2015, at 22:38, Christoph Becker cmbecke...@gmx.de wrote: And frankly, I don't see what's wrong with a weak type hint in this case: function addVat(float $amount) {...} You're returning a float, anyway. Given you’re dealing with currency, and given the fairly

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
I have similar opinion. Strict typing looks foreign for PHP. I see, strict type hints may be useful. Aspecially for testing and error detection, but anyaway, I'm not sure if and how it should be enabled. Declare() is a working solution, but it's not excelent. Thanks. Dmitry.

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Paul Dragoonis
Hi Dmitry, It's preferred to have flexible scalars, that way we can interchange between a numerical string or an integer. Over defining on such things loses the powerfulness of PHP. So scalar typehints are detrimental rather than useful. Saying something is a scalar or not, is useful however! :)

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Levi Morrison
A use case would be where scalar type hints are detrimental are: I implement an API that returns integers for entity ids, like 2,3,4,5,6. and my web-frontend handles this fine because it's a scalar. Then, you want to convert entity ids to UUID. This would break your entire web frontend

AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Robert Stoll
Hi Dimitry, -Ursprüngliche Nachricht- Von: Dmitry Stogov [mailto:dmi...@zend.com] Gesendet: Montag, 2. Februar 2015 10:13 An: PHP Internals; Andrea Faulds; Nikita Popov Betreff: [PHP-DEV] What do we need strict scalar type hints for? hi, could you please write down few use

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Stanislav Malyshev
Hi! Keeping that in mind, the declare statement, as ugly as it may look, could be actually a killer to finally get what both camps want but never (and never will) manage to agree. I think having two conceptual frameworks in one language and having to deal with (and potentially maintain) code

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
On Mon, Feb 2, 2015 at 9:05 PM, Pierre Joye pierre@gmail.com wrote: hi, On Mon, Feb 2, 2015 at 4:12 PM, Dmitry Stogov dmi...@zend.com wrote: hi, could you please write down few use cases, when strict scalar type hints are really useful. I think there is one big misunderstanding

AW: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Robert Stoll
-Ursprüngliche Nachricht- Von: Lester Caine [mailto:les...@lsces.co.uk] Gesendet: Montag, 2. Februar 2015 21:06 An: internals@lists.php.net Betreff: Re: [PHP-DEV] What do we need strict scalar type hints for? On 02/02/15 09:12, Dmitry Stogov wrote: could you please write down

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Pierre Joye
hi, On Mon, Feb 2, 2015 at 4:12 PM, Dmitry Stogov dmi...@zend.com wrote: hi, could you please write down few use cases, when strict scalar type hints are really useful. I think there is one big misunderstanding in Andrea's RFC. Strictness is local only. Or to say it in a better way, only

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
On Mon, Feb 2, 2015 at 7:47 PM, Paul Dragoonis dragoo...@gmail.com wrote: Hi Dmitry, It's preferred to have flexible scalars, that way we can interchange between a numerical string or an integer. Over defining on such things loses the powerfulness of PHP. So scalar typehints are

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Andrea Faulds
Hi Stas, On 2 Feb 2015, at 18:56, Stanislav Malyshev smalys...@gmail.com wrote: Hi! Keeping that in mind, the declare statement, as ugly as it may look, could be actually a killer to finally get what both camps want but never (and never will) manage to agree. I think having two

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
On Mon, Feb 2, 2015 at 9:41 PM, Robert Stoll p...@tutteli.ch wrote: Hi Dimitry, -Ursprüngliche Nachricht- Von: Dmitry Stogov [mailto:dmi...@zend.com] Gesendet: Montag, 2. Februar 2015 10:13 An: PHP Internals; Andrea Faulds; Nikita Popov Betreff: [PHP-DEV] What do we need

Re: [PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Jordi Boggiano
On 02/02/2015 18:56, Stanislav Malyshev wrote: Hi! Keeping that in mind, the declare statement, as ugly as it may look, could be actually a killer to finally get what both camps want but never (and never will) manage to agree. I think having two conceptual frameworks in one language and

[PHP-DEV] What do we need strict scalar type hints for?

2015-02-02 Thread Dmitry Stogov
hi, could you please write down few use cases, when strict scalar type hints are really useful. Thanks. Dmitry.