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
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
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
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
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,
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
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
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
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
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
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'
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
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
-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
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
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
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
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
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
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
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
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:
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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.
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
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
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
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
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]
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
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
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
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,
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()
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
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).'
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
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
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
-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
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
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__.'
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
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)
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);
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
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
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);
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
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
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
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.
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! :)
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
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
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
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
-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
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
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
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
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
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
hi,
could you please write down few use cases, when strict scalar type hints
are really useful.
Thanks. Dmitry.
78 matches
Mail list logo