[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 th

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

2016-03-18 Thread Dennis Birkholz
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 at some point but are > initially populated as strings.

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

2016-03-18 Thread Ryan Pallas
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 >> will error on attempted usage if not set. Should they instead error >> after the constructor has been called if they

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

2016-03-18 Thread Marco Pivetta
Hi Phil, On 16 March 2016 at 17:36, 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 fe

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

2016-03-18 Thread Larry Garfield
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 systems since ages (e.g. SQL where nullable fields are also

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

2016-03-18 Thread Phil Sturgeon
On Wed, Mar 16, 2016 at 6:17 PM, Andrey Andreev wrote: > On Thu, Mar 17, 2016 at 12:00 AM, Larry Garfield > wrote: > >> 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 pro

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

2016-03-18 Thread Björn Larsson
Den 2016-03-16 kl. 17:36, skrev 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

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

2016-03-18 Thread Net Mo
class SomeStruct{ public int $a; } class Joe { public SomeStruct $struct; function test1() : SomeStruct{ return new SomeStruct();// TypeError: can't return a type whose fields' type declarations aren't fulfilled } function test2(SomeStruct $struct){

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

2016-03-18 Thread Walter Parker
On Friday, March 18, 2016, 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 ma

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

2016-03-19 Thread Joe Watkins
Morning Lee, Phil is in a field somewhere, but I don't want to leave you hanging on for an answer ... so ... class Foo { public $bar; public function __get($name) { return 123; } } $foo = new Foo(); var_dump($foo->bar); You should not expect __get to be called in this ex

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

2016-03-19 Thread Phil Sturgeon
On Wed, Mar 16, 2016 at 12:49 PM, Will Fitch wrote: > > > 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/t

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

2016-03-19 Thread Andrea Faulds
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 language. There's a notable amount of places w

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

2016-03-19 Thread Andrey Andreev
On Thu, Mar 17, 2016 at 12:00 AM, Larry Garfield wrote: > 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 improve

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

2016-03-19 Thread Phil Sturgeon
Quick update folks, the RFC patch now respects strict mode, so will be weak by default and strict if enabled. I'll update the RFC to reflect this soon, but I'm busy today and it won't get done until tomorrow. Also there is definitely no void keyword for properties. We'll move onto working out de

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

2016-03-19 Thread Lee Davis
Hi all, first up, major thanks to both Joe and Phil for putting this together. I'm fully behind the concept of typed properties and think it would be a great feature to have in the language. I have a few points I'd like to make on the current implementation being proposed. 1) There's an issue

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

2016-03-19 Thread Larry Garfield
On 3/16/16 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 Overall thought: <3 I would really appreciate constructive feedback

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; >

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). Stil

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. >> >> https://wiki.php.net/rfc

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 properties,

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 a

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 system

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 ea

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 appreciate constructive feedba

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 th

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 o

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 incor

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 > >> will error on attempted usage if not set.

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

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: Unc

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 nothing instead of a > > s

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 identif

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; > } > > Af

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) and

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 = []; // No type, old code >

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 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 /n

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 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 f

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 only Joe Watkins. > > h

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 con

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 your code into 3v4l so y

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 no > > visibility > > i

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 doe

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 o

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 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 the language. > > > T

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 mo

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 anym

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. >> > > Or, do it like with

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 with parameter ty

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 bi

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. >> >> https://wiki.php.net/rfc

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 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 for an RFC, to add Typed Properties. The > >

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 w

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 > used in large projec

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 a

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

2016-03-19 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 sup

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

2016-03-19 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 properties as part of their p

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 temporary nullability situation, where unset properties > > will error

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 >> n

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 "Not sure how to implement it" and "Well

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 tha

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 th

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 langua

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 would be insane ;-) Sorr

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 il

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 feature

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 complet

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 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 thin

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, A

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 you

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 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 thank everyone for

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

2016-03-29 Thread Joe Watkins
next two days, I would start > working on it tomorrow. > > RFC itself looks fine. > > Thanks. Dmitry. > > > From: Phil Sturgeon > Sent: Tuesday, March 29, 2016 18:32 > To: Andrey Andreev > Cc: internals@lists.php.net > Subject: Re

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

2016-03-29 Thread Dmitry Stogov
Thanks. I'll start tomorrow morning and will try to send you update by the evening, From: Joe Watkins Sent: Tuesday, March 29, 2016 19:18 To: Dmitry Stogov Cc: Phil Sturgeon; krak...@php.net; internals@lists.php.net Subject: Re: [PHP-DEV] [RFC 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 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, which is great news. >> >> The R

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

2016-03-29 Thread Dmitry Stogov
ak...@php.net; internals@lists.php.net Subject: Re: [PHP-DEV] [RFC Discussion] Typed Properties Thanks. I'll start tomorrow morning and will try to send you update by the evening, From: Joe Watkins Sent: Tuesday, March 29, 2016 19:18 To: Dmitry Stogov Cc: Phil Sturgeo

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 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 property > A::$qux m

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

2016-03-29 Thread Joe Watkins
make proposal more consistent, but I assume you got some > troubles implementing it and I don't know about them yet. > > Thanks. Dmitry. > > > > From: Dmitry Stogov > Sent: Tuesday, March 29, 2016 19:24 > To: Joe Wat

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

2016-03-29 Thread Joe Watkins
rease 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 m

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 has good control over the

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 t

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, sho

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

2016-03-29 Thread Dmitry Stogov
Thanks. Dmitry. From: Dmitry Stogov 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 <

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

2016-03-29 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 no

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

2016-03-29 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" typed

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 values

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, but

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 value

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 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 typ

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 language

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, beca

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 "pub

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 the course of this discussio

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,

  1   2   >