Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71314 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41358 invoked from network); 20 Jan 2014 09:33:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2014 09:33:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=pthreads@pthreads.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=pthreads@pthreads.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain pthreads.org from 74.125.82.44 cause and error) X-PHP-List-Original-Sender: pthreads@pthreads.org X-Host-Fingerprint: 74.125.82.44 mail-wg0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:37397] helo=mail-wg0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/D7-02192-67DECD25 for ; Mon, 20 Jan 2014 04:33:42 -0500 Received: by mail-wg0-f44.google.com with SMTP id l18so6664117wgh.35 for ; Mon, 20 Jan 2014 01:33:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=lROkaFGRQ2jmTYNa6a/8CIeTC2qVtJ9lG1uJDmsgA34=; b=kcaCbMN+nZY3vsa4wDKlbaoH009esIpN3yoZl4mN2ppg4qk6D07A1RLP9KmG9AxPPS UiQvj+P4A8YZ2CKFZ1HOi4yK9BCGGG7yisJ89ak47U7JSDZLqx2XSUGjhvNm9mriddxn y4iA0J8m3v3eGGin+AZjATeJdUb5z+0aQVhSYOmhDsoKnymjr8AgDuHnDhXkrSRt5kSk ADdSQ2h7w9Gtco6THT0mBLgOdHXVaJgD3bYW+41K3wzOSxZNxnNca5Xr+KTyqbiQZJxN 2LKGL3bQ+GcLP3/mSsRGIXgcACnNZxUucs5QhInoJJnpEr0rjyrA/uqBDSMRtE1g8oyS SPEA== X-Gm-Message-State: ALoCoQk/yQbwX9jiOmplRjsdUzAFHNFs+L+ceranj45/riMwHL8exm+xnzm9G26DKe9akWRsL39q X-Received: by 10.180.86.198 with SMTP id r6mr8934976wiz.27.1390210419527; Mon, 20 Jan 2014 01:33:39 -0800 (PST) Received: from [192.168.43.248] (188.29.165.42.threembb.co.uk. [188.29.165.42]) by mx.google.com with ESMTPSA id ev4sm1181354wib.1.2014.01.20.01.33.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 20 Jan 2014 01:33:39 -0800 (PST) Message-ID: <52DCED71.3020207@pthreads.org> Date: Mon, 20 Jan 2014 09:33:37 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: internals@lists.php.net References: <002d01cf1234$01e6dc60$05b49520$@tutteli.ch> <004c01cf123d$35730870$a0591950$@tutteli.ch> <52D71748.1090402@googlemail.com> <52D71FAE.8030002@ajf.me> <005001cf124f$3a40df00$aec29d00$@tutteli.ch> <20140116110127.202079vzjsj76n7b@webmail.tutteli.ch> <0B.B1.24763.139B7D25@pb1.pair.com> <002001cf12da$2bfbda90$83f38fb0$@tutteli.ch> <52DCA3E7.80602@lerdorf.com> In-Reply-To: <52DCA3E7.80602@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Introducing "Array Of" RFC From: pthreads@pthreads.org (Joe Watkins) On 01/20/2014 04:19 AM, Rasmus Lerdorf wrote: > On 1/19/14, 9:13 AM, Philip Sturgeon wrote: >> I think its a nice logical improvement which syntactically offers a >> replacement for looney boilerplate code, exactly like Variadics which >> a LOT of people are excited about. > > Actually variadics solves a problem that can't be solved other ways, > namely by-ref for an unknown number of arguments. There is no userspace > boilerplate code, looney or otherwise, that can do that. > > I won't argue whether the base need is great enough here. I am sure it > is to some people. I do have an issue with the idea that the right > solution is a full hash table scan on every function call. I have a > feeling that if this makes it in this is one of those features that will > be high my list for optimization/refactoring when I run across it in > code. As in, replace the per-call hash scan with a single userspace scan > that is only done once earlier in the stack. From a performance > perspective the only-done-once userspace version is extremely likely to > outperform this built-in per-call check assuming more than a trivial > amount of calls to the function in question. > > -Rasmus > On 01/20/2014 04:19 AM, Rasmus Lerdorf wrote:> I do have an issue with the idea that the right > solution is a full hash table scan on every function call. Rasmus, The better solution here appears (to everyone else) to be generics, which you actually said you didn't want to see anywhere near PHP, please could you communicate your reasons for that ? I have concerns ... I'm concerned that type hinting isn't robust or complete enough to compliment using generics. I'm wary of the inherent complexity that generics carries both in it's implementation and usage. I'm concerned that we already have many different kinds of collection, and they have introduced inconsistencies (Traversable != array), I don't really see a way to add another, and such a complex one, without introducing more, or alternatively impacting everything. It's a bit crazy to implement a whole paradigm because we wanted a specific kind of type hint. Is it any of them ?? Is it something I, or any of the others thinking about generics, don't see ?? Do you, or anyone else, anyone at all, see a way to perform the simple type hint we set out to perform without incurring the overhead of a full table scan ? I don't want to set out to do anything that is bad, however, I think the performance thing is not really a massive concern, after all it's not very difficult for something innocent to incur a measurable overhead: https://eval.in/91920 And we're not all going around re-factoring our code to avoid that, because it's "normal"; people know that passing a huge array around increases memory usage because it's documented, so I don't see the problem with documenting how this would work such that those that need to avoid the overhead, can. Also, variadics incur the same overhead: http://lxr.php.net/xref/PHP_5_6/Zend/zend_vm_def.h#3448 The idea to change the hashtable wouldn't work anyway (for the OP of the idea): you can have a reference to a variable that is a member of an array and change it's type without executing any opcodes related to hashtable manipulation. Cheers Joe