Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-04-17 Thread Björn Larsson
Hi, Den 2016-04-06 kl. 18:33, skrev Phil Sturgeon: On Sat, Apr 2, 2016 at 3:10 PM, Björn Larsson wrote: Good evening,Den 2016-03-31 kl. 10:34, skrev Joe Watkins: Morning, Given that public is implied for all properties above there is a value in having the same

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-04-11 Thread Stephen Coakley
On 04/06/2016 11:33 AM, Phil Sturgeon wrote: We polled pretty hard and had a bunch of discussions about how multiple declarations should work, and ended up siding with Zeev and Larry, and all those others saying that type declarations should work for all just as visibility does currently:

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-04-07 Thread Phil Sturgeon
On Sat, Apr 2, 2016 at 3:10 PM, Björn Larsson wrote: > Good evening,Den 2016-03-31 kl. 10:34, skrev Joe Watkins: >> >> Morning, >> >>> Given that public is implied for all properties above there >>> is a value in having the same rule for type. >> >> public $bar, int

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-04-02 Thread Björn Larsson
Good evening,Den 2016-03-31 kl. 10:34, skrev Joe Watkins: Morning, Given that public is implied for all properties above there is a value in having the same rule for type. public $bar, int $foo; What does this mean? If it's not an error, what does this mean ? public $bar, int $foo, $qux;

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread guilhermebla...@gmail.com
My code version is not complete, as the references changed when you include the optional_type. It shouldn't be hard to change though... like $$ = $3 and also hold $2 somewhere. On Thu, Mar 31, 2016 at 2:09 PM, Zeev Suraski wrote: > > > On 31 במרץ 2016, at 20:48,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Zeev Suraski
> On 31 במרץ 2016, at 20:48, "guilhermebla...@gmail.com" > wrote: > > To me it's simply as that: > > > class_statement: >variable_modifiers optional_type property_list ';' { $$ = $2; > $$->attr = $1 } >| ... > > property_list: >property_list

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread guilhermebla...@gmail.com
;> <pjsturg...@gmail.com>; Krakjo <krak...@php.net>; PHP internals >>> <internals@lists.php.net> >>> Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties >>> >>> Morning Dmitry, >>> >>> This should be a error. I also think, tha

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Larry Garfield
>; Krakjo <krak...@php.net>; PHP internals <internals@lists.php.net> Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties Morning Dmitry, This should be a error. I also think, that "public" might be omitted, and it should be possible to write "int $bar, $foo"

RE: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Zeev Suraski
kjo <krak...@php.net>; PHP internals > <internals@lists.php.net> > Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties > > Morning Dmitry, > > > This should be a error. I also think, that "public" might be omitted, > > and it should be possible to writ

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Dmitry Stogov
On 03/31/2016 03:40 PM, Joe Watkins wrote: Morning Dmitry, > This should be a error. I also think, that "public" might > be omitted, and it should be possible to write "int $bar, $foo" Omitting public might be nice, but also totally separate, you should be able to omit it for untyped

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Joe Watkins
Morning Dmitry, > This should be a error. I also think, that "public" might > be omitted, and it should be possible to write "int $bar, $foo" Omitting public might be nice, but also totally separate, you should be able to omit it for untyped properties too. > You say - C, C++, Java, HHVM, etc -

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Rowan Collins
Hi Joe, Just my €0.02 Joe Watkins wrote on 31/03/2016 09:34: public $bar, int $foo; What does this mean? If it's not an error, what does this mean ? To me, that should be an error; why would you want to group typed and untyped properties on one line? public $bar, int $foo, $qux; If

RE: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Zeev Suraski
o <krak...@php.net>; PHP > internals <internals@lists.php.net> > Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties > > > > On 03/31/2016 11:34 AM, Joe Watkins wrote: > > Morning, > > > > > Given that public is implied for all properties above

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Dmitry Stogov
On 03/31/2016 11:34 AM, Joe Watkins wrote: Morning, > Given that public is implied for all properties above there > is a value in having the same rule for type. public $bar, int $foo; What does this mean? If it's not an error, what does this mean ? This should be a error. I also think,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-31 Thread Joe Watkins
Morning, > Given that public is implied for all properties above there > is a value in having the same rule for type. public $bar, int $foo; What does this mean? If it's not an error, what does this mean ? public $bar, int $foo, $qux; If it's an error, why is it an error ? Both of these

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Björn Larsson
Den 2016-03-30 kl. 05:16, skrev Joe Watkins: Morning Dmitry, 1) static typed properties are prohibited. why? Feels like that's a separate feature, static properties are as good as makes no difference, global variables. Instance properties, the engine has good control over their manipulation,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Björn Larsson
Den 2016-03-29 kl. 22:38, skrev Phil Sturgeon: On Tue, Mar 29, 2016 at 2:58 PM, Björn Larsson wrote: Den 2016-03-29 kl. 17:32, skrev Phil Sturgeon: I'd like to thank everyone for their feedback on this RFC! It looks like the majority of concerns were solved during

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Rowan Collins
Fleshgrinder wrote on 19/03/2016 10:48: It is a sad state the implicit public properties use*var* and implicit public methods nothing, this makes the introduction of new visibility modifiers terribly complicated. I see it a bit differently - you could think of "var $foo" as shorthand for

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Rowan Collins
Johannes Schlüter wrote on 30/03/2016 13:18: Maybe we should actually discuss making PHP fully typed and making that consistent instead of adding one piece of typing step by step. This gets an imaginary +1 from me. Function/method parameters and return types make sense as a special case,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Johannes Schlüter
On Wed, 2016-03-30 at 04:16 +0100, Joe Watkins wrote: > > 2) The handling of multiple properties in the same declaration statement > is inconsistent. > > This feels consistent to me .. in other languages where the type is > required, it makes sense to assume the type is implied. > > In a

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Lester Caine
On 30/03/16 09:31, Dmitry Stogov wrote: >> >> I hope this makes some of these decisions clearer ... > > One more thought about implicit initialization values. (int(0) for int > instead of IS_UNDEF). > I'm not sure if this RFC is going to be accepted yet, but lets think we > will also implement

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
class A { public int $b, string $c; // <- incompatible with HHVM } We don't have to be compatible with HHVM, but why to go against all the other languages. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
Few more related inconsistencies in current implementation. class A { public int $b; } $a = new A; var_dump($a); // <- prints A::b as NULL foreach ($a as $val) { var_dump($val); // <- prints NULL } All similar inconsistencies would be automatically solved with implicit default

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
On 03/30/2016 10:50 AM, Joe Watkins wrote: Morning Dmitry, > If we use one rule for arguments, why should we invent others. Properties are going to be nullable only if you explicitly initialise them with NULL. We didn't really invent anything, you are comparing them to parameters,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Joe Watkins
Morning Dmitry, > If we use one rule for arguments, why should we invent others. Properties are going to be nullable only if you explicitly initialise them with NULL. We didn't really invent anything, you are comparing them to parameters, but not return values ... strangely ... Return

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
On 03/30/2016 08:13 AM, Joe Watkins wrote: Morning Dmitry, So, I quickly reviewed the RFC and patch. Static properties, and mixed declarations, are now explained in the RFC. Thanks. I'm not agree with decisions, but RFC is more complete now. It would be great to have "static"

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
On 03/30/2016 07:26 AM, Joe Watkins wrote: Morning Pieere, Dmitry, all ... Actually it's not so simple ... for object properties we have ASSIGN_OBJ opcode, but we don't have a special opcode for static properties, and ASSIGN doesn't have any information about where the var came from, and

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-30 Thread Dmitry Stogov
___ From: Dmitry Stogov <dmi...@zend.com <mailto:dmi...@zend.com>> Sent: Tuesday, March 29, 2016 19:24 To: Joe Watkins Cc: Phil Sturgeon; krak...@php.net <mailto:krak...@php.net>; internals@lists.php.net <mailto:internals@lists.php.net> Subjec

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Joe Watkins
Morning Dmitry, So, I quickly reviewed the RFC and patch. Static properties, and mixed declarations, are now explained in the RFC. I made a couple of changes to the fetch_obj_w stuff, I'd be grateful if you could review that ... I didn't think I had got all possible combinations,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Joe Watkins
Morning Pieere, Dmitry, all ... Actually it's not so simple ... for object properties we have ASSIGN_OBJ opcode, but we don't have a special opcode for static properties, and ASSIGN doesn't have any information about where the var came from, and nor should it have that information ... I'm going

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Pierre Joye
On Mar 30, 2016 10:17 AM, "Joe Watkins" wrote: > > Morning Dmitry, > > > 1) static typed properties are prohibited. why? > > Feels like that's a separate feature, static properties are as good as > makes no difference, global variables. > > Instance properties, the engine

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Joe Watkins
going to >> decrease performance for each property access. It would be great to find a >> better solution. May be using zval.reserved. >> >> I assume, I didn't find all problems yet. >> >> I think, both RFC and implementation have problems. >> I may try to help with implementation. &g

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Joe Watkins
sume you got some > troubles implementing it and I don't know about them yet. > > Thanks. Dmitry. > > > > From: Dmitry Stogov <dmi...@zend.com> > Sent: Tuesday, March 29, 2016 19:24 > To: Joe Watkins > Cc: Phil Sturgeon; kra

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Ryan Pallas
On Tue, Mar 29, 2016 at 5:16 PM, Levi Morrison wrote: > > 2) The handling of multiple properties in the same declaration statement > is inconsistent. > > > > public int $bar, string $qux; // this works > > > > public int $bar, $qux; //this emits error: Untyped

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Levi Morrison
> 2) The handling of multiple properties in the same declaration statement is > inconsistent. > > public int $bar, string $qux; // this works > > public int $bar, $qux; //this emits error: Untyped property A::$qux > must not be mixed with typed properties > > It's better to allow

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Dmitry Stogov
v Cc: Phil Sturgeon; krak...@php.net; internals@lists.php.net Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties Hi Dmitry, The patch is pretty close to complete. When you start to dig a bit further, you'll notice that I prepared for using cached pointers to prop info, but,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Phil Sturgeon
On Tue, Mar 29, 2016 at 2:58 PM, Björn Larsson wrote: > Den 2016-03-29 kl. 17:32, skrev Phil Sturgeon: >> >> I'd like to thank everyone for their feedback on this RFC! >> >> It looks like the majority of concerns were solved during the course >> of this discussion,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Björn Larsson
Den 2016-03-29 kl. 17:32, skrev Phil Sturgeon: I'd like to thank everyone for their feedback on this RFC! It looks like the majority of concerns were solved during the course of this discussion, which is great news. The RFC has been expanded in a few areas to take care of a few other concerns,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Dmitry Stogov
: Andrey Andreev Cc: internals@lists.php.net<mailto:internals@lists.php.net> Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties I'd like to thank everyone for their feedback on this RFC! It looks like the majority of concerns were solved during the course of this discussion, which is great news.

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Joe Watkins
n next two days, I would start > working on it tomorrow. > > RFC itself looks fine. > > Thanks. Dmitry. > > > From: Phil Sturgeon <pjsturg...@gmail.com> > Sent: Tuesday, March 29, 2016 18:32 > To: Andrey Andreev > Cc: in

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Dmitry Stogov
on it tomorrow. RFC itself looks fine. Thanks. Dmitry. From: Phil Sturgeon <pjsturg...@gmail.com> Sent: Tuesday, March 29, 2016 18:32 To: Andrey Andreev Cc: internals@lists.php.net Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties I'd like to

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-29 Thread Phil Sturgeon
I'd like to thank everyone for their feedback on this RFC! It looks like the majority of concerns were solved during the course of this discussion, which is great news. The RFC has been expanded in a few areas to take care of a few other concerns, so please go and review it and let me know if

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Andrey Andreev
Hi again, Apparently I misunderstood the parts of the RFC that I was most concerned about (isset() and what causes magic method calls). Joe clarified most of it for me elsewhere and so now I'll be answering my own questions here, in case that helps anybody else: On Tue, Mar 22, 2016 at 9:26 PM,

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Andrea Faulds
Hi again, Fleshgrinder wrote: On 3/19/2016 9:32 PM, Andrea Faulds wrote: Fleshgrinder wrote: I see a big problem with the erroring no matter when as others already pointed out, e.g. together with named constructors (or factory methods if you prefer that name) but also with lazy loading. I

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Andrey Andreev
Hi, This mail turned out to look quite a lot like a rant - sorry about that. I can assure you I am genuinely looking for answers on the questions that follow ... https://3v4l.org/Lq5dA/rfc#tabs (an example is from the RFC itself) It doesn't make sense to me, for numerous reasons: 1. Why are any

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Rowan Collins
Björn Larsson wrote on 22/03/2016 15:04: Hm... In Hack the above code works, see: https://3v4l.org/nsA5W Well they have a different implementation as mentioned in the RFC, so no wonder. But they do have typed porperties in the language. It's not just a different implementation, it's a

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Björn Larsson
Den 2016-03-22 kl. 14:15, skrev Rowan Collins: Nikita Popov wrote on 21/03/2016 17:05: While it is no secret that we don't particularly like references, this is not the reason why they are forbidden. There is no conspiracy to punish users of references by denying them use of new typing

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-22 Thread Rowan Collins
Nikita Popov wrote on 21/03/2016 17:05: While it is no secret that we don't particularly like references, this is not the reason why they are forbidden. There is no conspiracy to punish users of references by denying them use of new typing features. No, the reasons here are technical. Let me

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-21 Thread Nikita Popov
On Mon, Mar 21, 2016 at 4:37 PM, Rowan Collins wrote: > Andrea Faulds wrote on 17/03/2016 22:32: > >> Hi Johannes, >> >> Johannes Schlüter wrote: >> >>> On Wed, 2016-03-16 at 19:15 +0100, Bob Weinand wrote: >>> Eih, only to typed properties. Everything else

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-21 Thread Rowan Collins
Andrea Faulds wrote on 17/03/2016 22:32: Hi Johannes, Johannes Schlüter wrote: On Wed, 2016-03-16 at 19:15 +0100, Bob Weinand wrote: Eih, only to typed properties. Everything else would be insane ;-) Sorry for being imprecise. Ok, quite a lot better, but still weird difference to the

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Johannes Schlüter
On Wed, 2016-03-16 at 12:36 -0400, Phil Sturgeon wrote: > Hello everyone, > > I have completed the draft for an RFC, to add Typed Properties. The > patch has been written by the one and only Joe Watkins. > > https://wiki.php.net/rfc/typed-properties I'm no fan of all this typing business, but

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Fleshgrinder
On 3/20/2016 2:19 PM, Fleshgrinder wrote: > On 3/19/2016 9:32 PM, Andrea Faulds wrote: >> This adds a loophole to property type checks which, as previously >> mentioned, prevents us from performing optimisations. I also don't see >> why internal functions should be treated specially here, given

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Phil Sturgeon
On Wed, Mar 16, 2016 at 1:08 PM, Adam Harvey wrote: > On 16 March 2016 at 09:36, Phil Sturgeon wrote: >> 3. Weak vs Strict. Right now this is entirely strict, with no >> declare() to change mode. Reasons for this vary, from various sources, >> but include

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Fleshgrinder
On 3/19/2016 9:32 PM, Andrea Faulds wrote: > Hi, > > Fleshgrinder wrote: >> I see a big problem with the erroring no matter when as others already >> pointed out, e.g. together with named constructors (or factory methods >> if you prefer that name) but also with lazy loading. I think that the >>

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Bob Weinand
> Am 16.03.2016 um 18:27 schrieb Chris Riley : > On 16 March 2016 at 17:17, Bob Weinand > wrote: > > Am 16.03.2016 um 17:36 schrieb Phil Sturgeon > >: > > 2. This whole

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Adam Harvey
On 16 March 2016 at 09:36, Phil Sturgeon wrote: > 3. Weak vs Strict. Right now this is entirely strict, with no > declare() to change mode. Reasons for this vary, from various sources, > but include "Not sure how to implement it" and "Well people should not > be using

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-20 Thread Crocodile
What about PDO's fetch-mode PDO::FETCH_CLASS? Apparently, it first fills in properties and then calls the constructor. Seems unlikely that the new behavior for uninitialized properties will cause a problem here, but sometimes weird things happen. And this is another thing to check. I also fully

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Matt Prelude
Hi, On 16/03/16 16:36, Phil Sturgeon wrote: 2. This whole temporary nullability situation, where unset properties will error on attempted usage if not set. Should they instead error after the constructor has been called if they are still not holding a value? I'd have the error at the time of

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Marco Pivetta
To answer my own question: the entire RFC is a no-go in its current state. On 18 March 2016 at 10:09, Marco Pivetta wrote: > That said, I have a few quite common use-cases that arise and that are a > bit problematic, both because they are hacks and because they are actually >

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/17/2016 9:03 AM, Benjamin Eberlei wrote: > Sorry to dampen your enthusiasm, but you are going slightly off topic here. > Package visibility was tried by Guilherme Blanco before, the way namespaces > are implemented this is not possible in PHP in an easy way. As far as i > understood him, its

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Chris Riley
On 16 March 2016 at 17:17, Bob Weinand wrote: > Hey, thank you both for investing your time :-) > Property types are definitely interesting. > > > Am 16.03.2016 um 17:36 schrieb Phil Sturgeon : > > > > Hello everyone, > > > > I have completed the draft

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Crocodile
Just an idea of a syntax for nullable properties. What about: /** * Can be null */ public int null $foo; /** * Can NOT be null */ public float $bar; This type of syntax has a long-living predecessor - SQL (INT NULL). I think it is readable and it does not introduce ambiguity as in string|null

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Bob Weinand
> Am 16.03.2016 um 18:39 schrieb Johannes Schlüter : > > On Wed, 2016-03-16 at 12:36 -0400, Phil Sturgeon wrote: >> Hello everyone, >> >> I have completed the draft for an RFC, to add Typed Properties. The >> patch has been written by the one and only Joe Watkins. >> >>

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Andrea Faulds
Hi, Fleshgrinder wrote: On 3/16/2016 5:36 PM, Phil Sturgeon wrote: 2. This whole temporary nullability situation, where unset properties will error on attempted usage if not set. Should they instead error after the constructor has been called if they are still not holding a value? I see a

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Andrey Andreev
Hi, On Thu, Mar 17, 2016 at 1:02 PM, Matt Prelude wrote: I'd support borrowing the "?" nullable annotation from HackLang for > people who want a less strict behavior: > > public ?string $name; > > This means that $name can either be a string or the NULL value. > Or, do it like

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Yasuo Ohgaki
Hi, On Thu, Mar 17, 2016 at 8:46 PM, Andrey Andreev wrote: > I'd support borrowing the "?" nullable annotation from HackLang for >> people who want a less strict behavior: >> >> public ?string $name; >> >> This means that $name can either be a string or the NULL value. >> > >

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Johannes Schlüter
On Wed, 2016-03-16 at 18:50 +0100, Bob Weinand wrote: > The patch currently prevents that. > It prevents all creation of references to properties. To all properties? Thus class C { private $data = []; // No type, old code public function sort() { sort($this->data); } } won't work

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread François Laupretre
Hi, Le 16/03/2016 17:36, Phil Sturgeon a écrit : Hello everyone, I have completed the draft for an RFC, to add Typed Properties. The patch has been written by the one and only Joe Watkins. https://wiki.php.net/rfc/typed-properties Maybe you can add a reference to a discussion we had some

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Bob Weinand
> Am 16.03.2016 um 19:41 schrieb Johannes Schlüter : > > On Wed, 2016-03-16 at 19:15 +0100, Bob Weinand wrote: >> >> Eih, only to typed properties. Everything else would be insane ;-) >> Sorry for being imprecise. > > Ok, quite a lot better, but still weird difference to

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Johannes Schlüter
On Wed, 2016-03-16 at 19:15 +0100, Bob Weinand wrote: > > Eih, only to typed properties. Everything else would be insane ;-) > Sorry for being imprecise. Ok, quite a lot better, but still weird difference to the language. There's a notable amount of places where references are being used and

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Larry Garfield
On 3/16/16 2:30 PM, Andrey Andreev wrote: Also, a LOT of code would end up with e.g. a default value of 0 for an integer property, still having to check if it was properly populated with a positive value - not much of an improvement over NULLs. Cheers, Andrey. That's fine. Type checking

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
Awesome feature thanks for the RFC. :) On 3/16/2016 5:36 PM, Phil Sturgeon wrote: > 1. How scared are we that integers can be expanded to floats on runtime? > This is already what happens in PHP all the time and I personally only see harm if we change that. People are already not understand what

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Benjamin Eberlei
On Wed, Mar 16, 2016 at 10:47 PM, Fleshgrinder wrote: > On 3/16/2016 10:12 PM, Björn Larsson wrote: > > Like the RFC :) > > > > Could this be an opportunity to have default visibility for property's > when > > they are typed in a similar fashion like for functions? Meaning

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Yasuo Ohgaki
Hi all, On Thu, Mar 17, 2016 at 8:30 AM, Johannes Schlüter wrote: > On Wed, 2016-03-16 at 15:29 -0400, Phil Sturgeon wrote: >> > What's expected here: >> > >> > class A { >> > public int $i; >> > } >> > >> > $a = new A(); >> > $r = &$a->i; >> > $r = "foobar"; > >> I put

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 19/03/16 12:31, Fleshgrinder wrote: >>> You are mixing to things like I did. If you never unset and never assign >>> >> then the value of the property is *null* or as I defined to avoid >>> >> confusion *void*. All fine. The question was, should this result in an >>> >> error and the general

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Bob Weinand
Hey, thank you both for investing your time :-) Property types are definitely interesting. > Am 16.03.2016 um 17:36 schrieb Phil Sturgeon : > > Hello everyone, > > I have completed the draft for an RFC, to add Typed Properties. The > patch has been written by the one and

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Will Fitch
On Wed, Mar 16, 2016, at 11:36 AM, Phil Sturgeon wrote: > Hello everyone, > > I have completed the draft for an RFC, to add Typed Properties. The > patch has been written by the one and only Joe Watkins. > > https://wiki.php.net/rfc/typed-properties > > I would really appreciate constructive

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/19/2016 1:29 PM, Lester Caine wrote: > On 19/03/16 12:17, Fleshgrinder wrote: >> You are mixing to things like I did. If you never unset and never assign >> then the value of the property is *null* or as I defined to avoid >> confusion *void*. All fine. The question was, should this result in

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 19/03/16 12:17, Fleshgrinder wrote: > You are mixing to things like I did. If you never unset and never assign > then the value of the property is *null* or as I defined to avoid > confusion *void*. All fine. The question was, should this result in an > error and the general consensus here is

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/19/2016 12:23 PM, Lester Caine wrote: > On 19/03/16 11:02, Fleshgrinder wrote: Properties need the ability to be void even after construction and it is >> up to the object to keep track and ensure state. Nullability is imho not >> necessary at all. So we are all in line here.

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Bob Weinand
> Am 16.03.2016 um 19:05 schrieb Johannes Schlüter : > > On Wed, 2016-03-16 at 18:50 +0100, Bob Weinand wrote: >> The patch currently prevents that. >> It prevents all creation of references to properties. > > To all properties? Thus > > class C { > private $data = [];

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
First a general note on the complete nullability first: It is not up to us as language designers to decide whether it is good practice to use nullable properties or not. It is supported by many systems since ages (e.g. SQL where nullable fields are also not recommended but heck they are useful)

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 18/03/16 10:55, Yasuo Ohgaki wrote: >> Although I'm all for limiting NULL to only being the default value: >> > >> > $this->name = null; // this should throw a TypeError > NULL is special type. '' and NULL is different entity. > > class User { > public string $username = NULL; > } > >

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 19/03/16 11:02, Fleshgrinder wrote: >>> Properties need the ability to be void even after construction and it is >>> >> up to the object to keep track and ensure state. Nullability is imho not >>> >> necessary at all. So we are all in line here. >> > >> > If the record I am working with

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Andrey Andreev
On Thu, Mar 17, 2016 at 12:23 AM, Phil Sturgeon wrote: > > Yet, your argument was about avoiding is_null() calls within application > > logic and you'd gain nothing if you end up having to write ! empty() > > instead. :) > > I'd rather have a NULL to tell me that I have

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Johannes Schlüter
On Wed, 2016-03-16 at 15:29 -0400, Phil Sturgeon wrote: > > What's expected here: > > > > class A { > > public int $i; > > } > > > > $a = new A(); > > $r = &$a->i; > > $r = "foobar"; > I put your code into 3v4l so you could see what would happen: > > https://3v4l.org/taC8D > > Fatal error:

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/19/2016 11:54 AM, Lester Caine wrote: > On 19/03/16 10:23, Fleshgrinder wrote: >> Properties need the ability to be void even after construction and it is >> up to the object to keep track and ensure state. Nullability is imho not >> necessary at all. So we are all in line here. > > If the

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Andrey Andreev
Hi, On Wed, Mar 16, 2016 at 9:21 PM, Ryan Pallas wrote: > On Wed, Mar 16, 2016 at 12:50 PM, Larry Garfield > wrote: > > > On 3/16/16 11:36 AM, Phil Sturgeon wrote: > > > >> > >> 2. This whole temporary nullability situation, where unset properties

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 19/03/16 10:23, Fleshgrinder wrote: > Properties need the ability to be void even after construction and it is > up to the object to keep track and ensure state. Nullability is imho not > necessary at all. So we are all in line here. If the record I am working with identifies elements are

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/19/2016 11:38 AM, Björn Larsson wrote: > Den 2016-03-18 kl. 21:12, skrev Fleshgrinder: >> No worries you are not, not at all. I just wanted to thwart you and >> others in directly assigning ... >> >> final class A { >> int $x; >> } >> >> ... to be *public* and obstruct the

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lester Caine
On 19/03/16 05:20, Walter Parker wrote: >> C A Horte, the famous computer scientist, calls the introduction of nulls > into his type system (like how Java did it decades later) to be his Billion > dollar mistake. He did it for the mathematical elegance and didn't foresee > all of the null errors

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Benjamin Eberlei
On Wed, Mar 16, 2016 at 5:36 PM, Phil Sturgeon wrote: > Hello everyone, > > I have completed the draft for an RFC, to add Typed Properties. The > patch has been written by the one and only Joe Watkins. > > https://wiki.php.net/rfc/typed-properties > > I would really

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Björn Larsson
Den 2016-03-18 kl. 21:12, skrev Fleshgrinder: On 3/17/2016 9:03 AM, Benjamin Eberlei wrote: Sorry to dampen your enthusiasm, but you are going slightly off topic here. Package visibility was tried by Guilherme Blanco before, the way namespaces are implemented this is not possible in PHP in an

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/19/2016 5:04 AM, Larry Garfield wrote: > On 03/18/2016 03:49 PM, Fleshgrinder wrote: >> First a general note on the complete nullability first: It is not up to >> us as language designers to decide whether it is good practice to use >> nullable properties or not. It is supported by many

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/18/2016 11:10 PM, Dennis Birkholz wrote: > Hi all, > > Am 16.03.2016 um 21:29 schrieb Fleshgrinder: >> Another more complicated user case would be *mysqli_fetch_object* that >> populates the properties with values from a storage but values that >> should become something specific and strict

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Joe Watkins
Morning Lee, > Makes sense. AccessTypeError, WriteTypeError to both extend TypeError? Well maybe ... I'm not sure there is much purpose in distinguishing between the two, while the engine doesn't make the distinction for normal untyped properties. If we make the distinction for typed

[PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Phil Sturgeon
Hello everyone, I have completed the draft for an RFC, to add Typed Properties. The patch has been written by the one and only Joe Watkins. https://wiki.php.net/rfc/typed-properties I would really appreciate constructive feedback on this RFC, with a few areas especially: 1. How scared are we

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Phil Sturgeon
On Wed, Mar 16, 2016 at 1:39 PM, Johannes Schlüter wrote: > On Wed, 2016-03-16 at 12:36 -0400, Phil Sturgeon wrote: >> Hello everyone, >> >> I have completed the draft for an RFC, to add Typed Properties. The >> patch has been written by the one and only Joe Watkins. >> >>

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Lee Davis
Hi Joe, > Accessing the property before it was unset though, as it always did, > attempts to read the default value (null). > > We haven't changed any of that ... > Yes, you're right, this is exactly how it currently behaves : https://3v4l.org/YpfYe (apologies for not checking this first).

Re: [PHP-DEV] [RFC Discussion] Typed Properties

2016-03-19 Thread Fleshgrinder
On 3/16/2016 10:12 PM, Björn Larsson wrote: > Like the RFC :) > > Could this be an opportunity to have default visibility for property's when > they are typed in a similar fashion like for functions? Meaning no > visibility > implies public and code below would work. > class A { > int $i=7; >

  1   2   >