Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89909 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87600 invoked from network); 28 Dec 2015 15:15:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Dec 2015 15:15:22 -0000 Received: from [127.0.0.1] ([127.0.0.1:3831]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id F2/C3-51216-90251865 for ; Mon, 28 Dec 2015 10:15:21 -0500 Authentication-Results: pb1.pair.com header.from=tomac120@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tomac120@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.172 as permitted sender) X-PHP-List-Original-Sender: tomac120@gmail.com X-Host-Fingerprint: 209.85.214.172 mail-ob0-f172.google.com Received: from [209.85.214.172] ([209.85.214.172:34635] helo=mail-ob0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/B3-51216-85F41865 for ; Mon, 28 Dec 2015 10:03:53 -0500 Received: by mail-ob0-f172.google.com with SMTP id wp13so7660754obc.1 for ; Mon, 28 Dec 2015 07:03:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=cmTjZxVa3Aj/PV3kYQbx0G7TeewbU0hph6Dy+7zdRqw=; b=SPZC2GeBItQR86ZPGcKBllkK7wI57g1ItFd5RdaZN9bRfAO3n+neoVWph2TrjnnxOI cLNrL5Chptk/sBsNFQeenjf+scpx1h4aYLUxUV+Qr5TUK+jph0oPoOB6NXdziKqfaQJd rLK6DqhPkcc8KFC2o0ow+g+TuHz7Aa99PgcJ3x0knMLiUfJIf1cvM9+DB5b+Rw873+Ms dgCQ1teTk3pWeUBzleoZCEucfwwxV3s4anshsPBmRG8D4GMJW4bdSoE7rnhlzEFnY4+k JqiJbxij0rkiGo01w4lKdbEmN73ig2KpaBUMKgB+764cbENLOwEHKgAzvXQ/Pn4rYgDw b8pA== MIME-Version: 1.0 X-Received: by 10.60.159.230 with SMTP id xf6mr32611842oeb.43.1451315030338; Mon, 28 Dec 2015 07:03:50 -0800 (PST) Sender: tomac120@gmail.com Received: by 10.202.220.212 with HTTP; Mon, 28 Dec 2015 07:03:50 -0800 (PST) In-Reply-To: <56811E49.1040106@php.net> References: <56811E49.1040106@php.net> Date: Mon, 28 Dec 2015 10:03:50 -0500 X-Google-Sender-Auth: YafBPZeGo8EUSt_WoWmRuYQhqu8 Message-ID: To: =?UTF-8?Q?Fran=C3=A7ois_Laupretre?= Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=047d7bd6a9d6d731460527f69c27 Subject: Re: [PHP-DEV] Make strict mode more strict? From: ejrx7753@gmail.com (Elijah Johnson) --047d7bd6a9d6d731460527f69c27 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, On Mon, Dec 28, 2015 at 6:34 AM, Fran=C3=A7ois Laupretre wrote: > Hi, > > Le 26/12/2015 21:35, Elijah Johnson a =C3=A9crit : > >> Can you explain your statement that this would be a huge and complex >> work? You must mean that there would be multiple places in the php sourc= e >> code where variables are assigned? I'm not yet discussing performance, b= ut >> only the aspect of adding the feature. >> > > There may other options I don't know but, AFAIK, this implies adding an > optional type hint at the zval level. This type hint should be verified a= t > least before each conversion. Copy-on-write is an other issue, as it is > currently not compatible with zval type hints. Seeing only variables with > well-defined names, and focusing on arrays, only scratches the surface. > Everything happens at the zval level. So, IMO, attaching type hints to > variables and properties is a huge and complex work. > > Regards > > Fran=C3=A7ois > I think I see what you are saying. Copy on write takes a reference to the entire z-val in two local variables, so a type-hint at the z-val level would be shared. This returns us to the insight of the original mailer who suggested that an object or array variable should be typed by its first-assigned object. This would simply need to be a global mode - stack-mode-legacy, stack-mode-static-object-types, and stack-mode-super-strict for those who want basic types also. I'm not saying that this is ideal, just that we need to compromise a bit to accommodate our existing code base and performance issues. The proposal for an additional z-val which stores the class name in the zval.value member and is counted as null could accommodate the case where the user wants to assign the type before he has an object. I think this is the best option. Another theory I had was to store the types at the context level in some kind of array, but its really too much. The idea just now proposed of 3 global modes will eliminate the issue of storing at the z-val level. The mode "stack-mode-static-object-types" is even already compatible with every line of code that I have properly written in PHP. --047d7bd6a9d6d731460527f69c27--