Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101016 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17649 invoked from network); 1 Nov 2017 14:41:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Nov 2017 14:41:03 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:45535] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6B/EA-07742-EFCD9F95 for ; Wed, 01 Nov 2017 09:41:02 -0500 Received: by mail-wm0-f47.google.com with SMTP id y80so5245813wmd.0 for ; Wed, 01 Nov 2017 07:41:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=VIJ4XoOEVhIqrSgL+BUrgQLjn/3PL8+PzOnly8wjpSw=; b=MckD+BC30Xy5tGz07Zzt3pQ056X9yv+mTXc9OpUoptRG7ZSLfa+1ZS6Ci3lQpCxwYA u6+tIlZE2akSOMM/bTMEoOl08CZYXiBUgNqAaArpys/dxcy4Ik68Dxo0siJqmJLcS5bx Qfu0KO7qsHjOYoGdbHyKEqd3WADbIQuqd6g53R+VFBsj9Wk5lWfwXTO8X6hl7TAtGg3K WXbGoHmNujqCcJiu5SEmpjXFhA5MbbfZPcEZR0oaSJJQ3JdOSkgZqOrf2w1zLoEF1p4r Tci1YukXzeUu6FQPnAZH9tE+99Vl9B2nnAI4ctczgcTkoq05xyEGBbsPN14JnPhJ8Bff yjjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=VIJ4XoOEVhIqrSgL+BUrgQLjn/3PL8+PzOnly8wjpSw=; b=AGl0WvnUmU32aYZv2TaupvEs6+TxO3uVUKx3gh8RieQeEeh9Q5PPjPTfd+zbFVS1wi ULRuO6xrAyKxIFJEOLJkI7sKWpfHnzx9ozB4Od3N77l5p6yMtz4HtYbv9kyFeHq5kjPb zYzSUEw7gjFGV6qh/JheHievDAZggBzu866yuL9lFGyGQLsLY/hmaOTKZqnQgvsGXL0G 88RN7Z+RjcUwkm4YNp5QmN0qqlcTIs33j/k55k+hzl7vL64ohPJzXaZYjCFUzdr8yxOX LmlTusGooFcCGbp2G3lTP4ML2YjCSKbXT/PrUDHLGIjh0+C6+SSPTkiEO8t2unFRVvZm Utow== X-Gm-Message-State: AMCzsaVki9Z3+16Xf3Ohq/VU8wZOoEYMCWb4BkQa/hkH/po/wMBBY//h U1f1PTAUOxoev1g+ESUnL+4pY+gi X-Google-Smtp-Source: ABhQp+TBa1DEIGeHWLFmw/qV8t+XppzmkJsfxixlJDZJSO8PlstOSeapkgqsD/C0pNqWmWba1B3/Bg== X-Received: by 10.80.136.101 with SMTP id c34mr641527edc.300.1509547259134; Wed, 01 Nov 2017 07:40:59 -0700 (PDT) Received: from [10.61.110.88] (188.29.165.35.threembb.co.uk. [188.29.165.35]) by smtp.gmail.com with ESMTPSA id m23sm1707906edc.53.2017.11.01.07.40.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Nov 2017 07:40:58 -0700 (PDT) Date: Wed, 01 Nov 2017 14:40:55 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <2C3A2443-8680-4FA7-BD25-872472506D03@gmail.com> Subject: Re: [PHP-DEV] RFC - Array Of for PHP 7 From: rowan.collins@gmail.com (Rowan Collins) On 31 October 2017 17:37:17 GMT+00:00, Levi Morrison wrot= e: > - Our current infrastructure requires us to check every element of >the array for conformance=2E While undesirable I believe this can be >optimized away in the future if we care enough, and therefore not a >show-stopper=2E Do you have a mechanism in mind for "optimising this away"? I think releas= ing the feature without any optimisation will just lead to painful slowdown= s when people use it without realising the implications=2E As I said in my previous message, it seems to be a fundamental issue with = PHP's current type declarations that they are a) runtime, and b) asserted a= t arbitrary points, not at assignment=2E So even if you optimise the check = slightly, it's still a separate check every time you enter a new function, = which puts a limit on optimisation=2E The only way I've thought of to improve things is to cache the result of p= revious type checks, but this comes with all the normal challenges of cachi= ng=2E For instance, all assignments into the array would need to invalidate= these cached checks, or check the new value against each=2E References wou= ld be particularly tricky, as they were with the property type hint proposa= l=2E If we selectively invalidated cached checks, we'd be running specific type= checks at every variable assignment, but not letting the user actually ass= ert on those checks=2E At which point, should we approach from the other di= rection, and let the user declare variable types, rather than assert value = types?=20 This is kind of implied if we implement generics, too, since explicitly co= nstructing an instance of list is asking the runtime to check future a= ssignments to members of that list=2E In effect, could declaring "int $foo = =3D 42;" be considered equivalent to "$foo =3D new checkedScalar(42);"= ? Regards, --=20 Rowan Collins [IMSoP]