Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103407 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25996 invoked from network); 28 Oct 2018 06:38:26 -0000 Received: from unknown (HELO mail-lj1-f181.google.com) (209.85.208.181) by pb1.pair.com with SMTP; 28 Oct 2018 06:38:26 -0000 Received: by mail-lj1-f181.google.com with SMTP id t22-v6so4587822lji.7 for ; Sat, 27 Oct 2018 19:54:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=900AdbGTrRd81wagFg7bFk6dY/h29zU49QDDZ4Yjak8=; b=KWj5tRpWa4gKM/bzsMIaY6lW6fjvnDEagm8aopUJ7s0RUc0W70T7YX9/8lvjKWzlgI HhLwFgN5HrJXD7bE6rhZu1n5UoSIJOYFQ6ZCRlsfkJexcLASGzpYaV4XTOO13B3aU/sY xngdJhR36yBazbBBHKZtJ5HuhD3A5MpUald9JVqI42VTYJH1mBW/vYSeGzqoimYrvcst CeY7LKEUWzX5zycF1yy6qF6t6ArbFWmu5Ul8WxdNJY4FpKdyDJ9ZYaValbKVq1csIYAN I6O0EsZEnPzdIqCGkXxm4GEIGJdbqqdplub2AgtJaeuOfmRXz9x33Cstz4eM7RFalqAk D+Rg== X-Gm-Message-State: AGRZ1gJ+SvEAcIKjlu+WpTbIIahVyWeBDtocFkO8RXHP3V/e1PTnex2b Fdpwa1L8d3xaA4nzKpbSChBCM3TWE0Y4TRbHVEw= X-Google-Smtp-Source: AJdET5fJQLRgG1CKuLjddobBC5kKIpuiwqtgC8GFEcpQ5ft5pCfdN0Dk1brjHRF4IBqiKi/T0XPu80UCiVZG0BwUxVA= X-Received: by 2002:a2e:8eca:: with SMTP id e10-v6mr2983414ljl.109.1540695267116; Sat, 27 Oct 2018 19:54:27 -0700 (PDT) MIME-Version: 1.0 References: <2370262.6EcsR2toYx@vulcan> In-Reply-To: Date: Sat, 27 Oct 2018 20:54:04 -0600 Message-ID: To: Kalle Sommer Nielsen Cc: Larry Garfield , internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Idea for better function callbacks (another syntactic sugar) From: levim@php.net (Levi Morrison) On Fri, Oct 26, 2018 at 3:09 PM Kalle Sommer Nielsen wrote: > > Den fre. 26. okt. 2018 kl. 18.03 skrev Levi Morrison : > > In my opinion "ideal" here is that our symbol tables are merged, so > > referring to "trim" in any context will resolve to at most one symbol, > > *and* that we also have a short-closure syntax for times when there > > isn't a *perfect* function to use. > > > > In the next version of PHP I would really like to see some warnings > > for when symbol names get re-used so that in the future we can merge > > them with less of a BC break. > > I like that idea a lot tbh, but I do worry a lot about the lookup time > if we end up with a gigantic hashtable to hold all the symbols and the > implications it has. In most contexts we know (based on the syntax) > what we are looking for, however as it currently stands then it would > not be clear wether to look for the constant "trim" or the procedural > function "trim" in the example given, and if thats all the same, I can > see that many things not utilizing this could be slower for no good > reason (at least in my honest opinion). However I don't know if there > is something sneaky we can do here. The symbols will probably kept in separate tables even after the change, with the order being determined by context. I don't worry about this performance hit, because callbacks are already so slow I don't think an extra hash lookup or two in the worst case will make this worse. And in some cases string callables have overhead at runtime because they have to search for "::", although I'm not up-to-date on where exactly we do this (it was looked into at one point).