Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:77657 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59604 invoked from network); 26 Sep 2014 08:46:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Sep 2014 08:46:46 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:39645] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/66-27411-4F725245 for ; Fri, 26 Sep 2014 04:46:44 -0400 Received: (qmail 26877 invoked by uid 89); 26 Sep 2014 08:46:41 -0000 Received: by simscan 1.3.1 ppid: 26870, pid: 26873, t: 0.0895s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.8?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 26 Sep 2014 08:46:41 -0000 Message-ID: <542527F1.6090603@lsces.co.uk> Date: Fri, 26 Sep 2014 09:46:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: internals@lists.php.net References: <54213481.8080700@php.net> <54213ECC.5080204@php.net> <54214E57.3080200@php.net> <54220B80.5050208@sugarcrm.com> <54225D5B.3030402@php.net> <54226509.8080405@sugarcrm.com> <54227E98.3050402@php.net> <54231E06.90208@sugarcrm.com> <9E9CD624-B581-417B-9C9D-5202CA84D52D@ajf.me> <54251785.80907@sugarcrm.com> In-Reply-To: <54251785.80907@sugarcrm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Invokation on __toString() for object used as array key From: lester@lsces.co.uk (Lester Caine) On 26/09/14 08:36, Stas Malyshev wrote: >> I think it makes more sense than a new method on all objects. You could > Nobody talks about "new method on all objects" (it's also not really > possible in PHP). We're talking about new magic method, which allows the > developer to control how class is treated when used as hash key. Note it > is not always the same as object's identity - you may want two GMP > numbers with value of "1" actually refer to the same key in the hash, > just like two numbers 1 do. This is actually the one I'm trying to work around ... The key is well defined as it's the BIGINT value on the database but I am unsure exactly what is going on with all the discussions on 64 bit processing if the same integer key will be available on 32bit builds. Which is where what other 'hash/simple assign' methods return is something that would be nice to know. For different builds to produce completely different results is a problem, but since in my book __toString() simply needs to be manually populated anyway, populating it with something suitable is not a problem. I don't see how anything 'memory location' based makes a sensible default for that? Automatically populating with something content based is simply not practical? So adding a __toHash does not provide any gain since it has the same problem? The main advantage of PHP is that it IS loosely defined so we can bend it to our own way of working, so some 'defaults' would be better as simply better documented explanations on why manual assistance is more appropriate. __toString() is one of those cases. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk