Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2015-01-05 Thread Pascal Martin, AFUP
On 16/12/2014 09:34, Stanislav Malyshev wrote: I'd like to initiate a vote on "objects as keys" RFC: https://wiki.php.net/rfc/objkey Hi, After discussing this RFC with other members of AFUP, we would probably be +1 on the idea of being able to really use objects as keys. But, considering thi

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-18 Thread Christoph Becker
Lester Caine wrote: > On 18/12/14 09:03, Stanislav Malyshev wrote: >>> Luckily, we have SplObjectStorage, which maybe makes that rather less urgent as well. >> SplObjectStorage doesn't do this - SplObjectStorage uses objects' >> identity, which means two GMP(1)'s are different objects. > > S

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-18 Thread Lester Caine
On 18/12/14 09:03, Stanislav Malyshev wrote: >> Luckily, we have SplObjectStorage, which maybe makes that rather less >> > urgent as well. > SplObjectStorage doesn't do this - SplObjectStorage uses objects' > identity, which means two GMP(1)'s are different objects. Silly question time again ...

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-18 Thread Stanislav Malyshev
Hi! > Luckily, we have SplObjectStorage, which maybe makes that rather less > urgent as well. SplObjectStorage doesn't do this - SplObjectStorage uses objects' identity, which means two GMP(1)'s are different objects. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Develop

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread guilhermebla...@gmail.com
Hi, I originally considered you could retrieve the object key, but if it is not possible by this RFC, I will switch my vote to no. By storing hash one way it introduces a huge wtf to the language. Cheers, On Dec 17, 2014 8:40 PM, "Rowan Collins" wrote: > On 17/12/2014 22:05, Rowan Collins wrot

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Levi Morrison
>> Programmable hashes of objects should be external to the object anyway >> because eventually someone wants to store the same object in a >> different way in two different structures. > > That is the requirement that no language I can think of implements - > Java, Python, Ruby, C# all have progra

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Rowan Collins
On 17/12/2014 22:05, Rowan Collins wrote: For one thing, I think it might be interesting to explore whether real objects as keys is actually as difficult as some people are assuming. I can naively imagine a few ways it could be implemented that seem in my mind to have minimal impact on any arra

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Rowan Collins
On 17/12/2014 16:58, Stanislav Malyshev wrote: Hi! I wonder why you opened voting on this, before resolving the "Open Issues": Open Issues Should SplFixedArray support object indexes? Should SplObjectStorage support calling __hash for an object if it exists? These issues are not pa

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Rowan Collins
On 17/12/2014 17:03, Stanislav Malyshev wrote: Hi! As I said in the original discussion: this RFC is actually about having an implicit call to __hash() whenever an object is used as an array key. You can achieve exactly the same in userland with an explicit call. It's like nobody have ever see

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Stanislav Malyshev
Hi! > Just because you say it doesn't affect it doesn't mean it doesn't. I > think it would be quite silly to support storing hashes and/or storing > objects and to me that blocks the latter since you are proposing the > former. I don't know why you think it's "quite silly" to have both scalar an

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Leigh
On 16 December 2014 at 08:34, Stanislav Malyshev wrote: > Hi! > > I'd like to initiate a vote on "objects as keys" RFC: > https://wiki.php.net/rfc/objkey > > I know this is a holiday season but it was extensively discussed and I > think most people already formed their opinions. I've put the votin

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Levi Morrison
>> and likely prevents us >> from adding support for objects as keys in the future should we want > > No it does not. It was already explained several times. If it is ever > introduced, it can be used for objects that do not explicitly request > functionality in this RFC by enabling __hash() with n

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Stanislav Malyshev
Hi! > This RFC proposes that we store the hash of an object instead of the > actual object. That's simply not useful to me Fair enough, but this is not only about what is useful personally to you. > and likely prevents us > from adding support for objects as keys in the future should we want N

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Levi Morrison
This RFC proposes that we store the hash of an object instead of the actual object. That's simply not useful to me and likely prevents us from adding support for objects as keys in the future should we want it. In addition, it adds yet another behavior to arrays which do so many things already. I

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Stanislav Malyshev
Hi! > As I said in the original discussion: this RFC is actually about having > an implicit call to __hash() whenever an object is used as an array key. > You can achieve exactly the same in userland with an explicit call. It's like nobody have ever seen __toString before... Of course you can do

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Stanislav Malyshev
Hi! > I wonder why you opened voting on this, before resolving the "Open > Issues": > > Open Issues > > Should SplFixedArray support object indexes? > Should SplObjectStorage support calling __hash for an object if it exists? These issues are not part of the RFC's target, they are poss

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Christoph Becker
Stanislav Malyshev wrote: >> Yes, but it is already possible to call an object's method in array key >> context, so in combination with an appropriate interface the same can be >> accomplished. > > No, it's not possible. It is possible to call object method in an > expression, and then use the re

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Rowan Collins
guilhermebla...@gmail.com wrote on 17/12/2014 12:43: Answering the question of Christopher Becker. It is not possible to traverse and get your desired elements. How would you achieve a foreach by key (returning object) without having to store a separate list and track by hash or through an interf

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Christoph Becker
Rowan Collins wrote: > Stanislav Malyshev wrote on 17/12/2014 02:14: >> No, it's not possible. It is possible to call object method in an >> expression, and then use the result of the expression as an array key. >> But to do that you'd have to check that you're dealing with the object >> and the c

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Etienne Kneuss
On Wed Dec 17 2014 at 1:44:13 PM guilhermebla...@gmail.com < guilhermebla...@gmail.com> wrote: > Hi, > > Answering the question of Christopher Becker. It is not possible to > traverse and get your desired elements. > How would you achieve a foreach by key (returning object) without having to > sto

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Christoph Becker
guilhermebla...@gmail.com wrote: > Answering the question of Christopher Becker. It is not possible to > traverse and get your desired elements. > How would you achieve a foreach by key (returning object) without having to > store a separate list and track by hash or through an interface? AIUI, t

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread guilhermebla...@gmail.com
Hi, Answering the question of Christopher Becker. It is not possible to traverse and get your desired elements. How would you achieve a foreach by key (returning object) without having to store a separate list and track by hash or through an interface? Cheers, On Wed, Dec 17, 2014 at 10:04 AM, D

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Derick Rethans
On Tue, 16 Dec 2014, Stanislav Malyshev wrote: > I'd like to initiate a vote on "objects as keys" RFC: > https://wiki.php.net/rfc/objkey I wonder why you opened voting on this, before resolving the "Open Issues": Open Issues Should SplFixedArray support object indexes? Should SplObject

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-17 Thread Rowan Collins
Stanislav Malyshev wrote on 17/12/2014 02:14: No, it's not possible. It is possible to call object method in an expression, and then use the result of the expression as an array key. But to do that you'd have to check that you're dealing with the object and the call the special method. I think

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Stanislav Malyshev
Hi! > Yes, but it is already possible to call an object's method in array key > context, so in combination with an appropriate interface the same can be > accomplished. No, it's not possible. It is possible to call object method in an expression, and then use the result of the expression as an ar

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Stanislav Malyshev
Hi! >> On 17 Dec 2014, at 01:32, Stanislav Malyshev >> wrote: >> >> Hi! >> >>> AIUI, this RFC is meant to introduce some sugar only. Wouldn't >>> it be >> >> I'm not sure what you mean by "some sugar only". It introduces the >> capability of using objects in array key context, which was not

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Christoph Becker
Stanislav Malyshev wrote: >> AIUI, this RFC is meant to introduce some sugar only. Wouldn't it be > > I'm not sure what you mean by "some sugar only". It introduces the > capability of using objects in array key context, which was not > available until now. Yes, but it is already possible to ca

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Andrea Faulds
Hi Stas, > On 17 Dec 2014, at 01:32, Stanislav Malyshev wrote: > > Hi! > >> AIUI, this RFC is meant to introduce some sugar only. Wouldn't it be > > I'm not sure what you mean by "some sugar only". It introduces the > capability of using objects in array key context, which was not > available

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Stanislav Malyshev
Hi! > AIUI, this RFC is meant to introduce some sugar only. Wouldn't it be I'm not sure what you mean by "some sugar only". It introduces the capability of using objects in array key context, which was not available until now. > possible to have object hashes without __hash(), by introducing a

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Christoph Becker
guilhermebla...@gmail.com wrote: > On Tue, Dec 16, 2014 at 9:39 AM, Matteo Beccati > wrote: > >> Are you sure you haven't misinterpreted the RFC? > > I did not. You may think I mentioned IdentityMap as entity map, but I'm > talking about entityPersister mapping or resultPointers consumptions tha

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread guilhermebla...@gmail.com
> On Tue, Dec 16, 2014 at 9:39 AM, Matteo Beccati wrote:Hi Guilherme, > >> On 16/12/2014 12:34, Guilherme Blanco wrote: >> Hi, >> All I can say is that the lack of this feature is one of the main reasons why Doctrine doesn't fully work with composite keys. >> With this enhancement it would now bec

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Rowan Collins
On 16 December 2014 18:50:06 GMT, Stanislav Malyshev wrote: >Hi! > >> Explicit conversion is trivial, just call whatever method you like. >> Sure, you can't write (int)$obj, but $obj->toInt() is just as >> expressive. > >Exactly the same applies to __toString and whole ArrayAccess, yet we >still

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Stanislav Malyshev
Hi! > Explicit conversion is trivial, just call whatever method you like. > Sure, you can't write (int)$obj, but $obj->toInt() is just as > expressive. Exactly the same applies to __toString and whole ArrayAccess, yet we still have them. Avoiding boilerplate code helps. Especially if boilterplate

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Rowan Collins
On 16 December 2014 18:14:27 GMT, Stanislav Malyshev wrote: >Hi! > >> I was previously in favour of this, but it’d prevent actual indexing > >No, of course it won't - if we ever introduce indexing objects (which >probably will require rewrite of the HashTable, any takers?) it would >be >very eas

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Stanislav Malyshev
Hi! > I was previously in favour of this, but it’d prevent actual indexing No, of course it won't - if we ever introduce indexing objects (which probably will require rewrite of the HashTable, any takers?) it would be very easy to index any object that does not implement __hash without any BC pr

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Florian Margaine
Hi, Le 16 déc. 2014 13:45, "Rowan Collins" a écrit : > > Patrick Schaaf wrote on 16/12/2014 11:46: > >> Am 16.12.2014 12:36 schrieb "Matteo Beccati" : >>> >>> On 16/12/2014 11:52, Andrea Faulds wrote: I was previously in favour of this, but it’d prevent actual indexing by objects i

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Rowan Collins
Patrick Schaaf wrote on 16/12/2014 11:46: Am 16.12.2014 12:36 schrieb "Matteo Beccati" : On 16/12/2014 11:52, Andrea Faulds wrote: I was previously in favour of this, but it’d prevent actual indexing by objects in future, and I can’t think of any use cases which aren’t better solved by explicit

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Patrick Schaaf
Am 16.12.2014 12:36 schrieb "Matteo Beccati" : > > On 16/12/2014 11:52, Andrea Faulds wrote: >> >> I was previously in favour of this, but it’d prevent actual indexing >> by objects in future, and I can’t think of any use cases which aren’t >> better solved by explicitly converting to a string/inte

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Matteo Beccati
Hi Guilherme, On 16/12/2014 12:34, Guilherme Blanco wrote: Hi, All I can say is that the lack of this feature is one of the main reasons why Doctrine doesn't fully work with composite keys. With this enhancement it would now become possible to implement a proper IdentityMap. Are you sure yo

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Matteo Beccati
On 16/12/2014 11:52, Andrea Faulds wrote: This is the main problem with the RFC: magic, implicit, one-way data loss (object to integer/string). I was previously in favour of this, but it’d prevent actual indexing by objects in future, and I can’t think of any use cases which aren’t better solved

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Guilherme Blanco
Hi, All I can say is that the lack of this feature is one of the main reasons why Doctrine doesn't fully work with composite keys. With this enhancement it would now become possible to implement a proper IdentityMap. []s, On Dec 16, 2014, at 9:05 AM, Andrea Faulds wrote: >> >> On 16 Dec 201

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Andrea Faulds
> > On 16 Dec 2014, at 10:52, Andrea Faulds wrote: > > Exactly. If I were to do this: > >class Foo { >public $foo; >function __construct($foo) { >$this->foo = $foo; >} >function __toKey() { >return $this->foo; >} >} >

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Andrea Faulds
Hi Markus, > On 16 Dec 2014, at 10:31, Markus Fischer wrote: > > On 16.12.14 09:34, Stanislav Malyshev wrote: >> I'd like to initiate a vote on "objects as keys" RFC: >> https://wiki.php.net/rfc/objkey > > Am I right this only covers the transformation into the array. Once it's > in it's essent

Re: [PHP-DEV] [RFC][VOTE] Objects as Keys

2014-12-16 Thread Markus Fischer
On 16.12.14 09:34, Stanislav Malyshev wrote: > I'd like to initiate a vote on "objects as keys" RFC: > https://wiki.php.net/rfc/objkey Am I right this only covers the transformation into the array. Once it's in it's essential a array compatible key entity (string/integer) so when you var_dump($arr