Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101536 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65578 invoked from network); 4 Jan 2018 21:10:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jan 2018 21:10:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.50 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.50 mail-lf0-f50.google.com Received: from [209.85.215.50] ([209.85.215.50:43335] helo=mail-lf0-f50.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/C3-45945-8289E4A5 for ; Thu, 04 Jan 2018 16:10:02 -0500 Received: by mail-lf0-f50.google.com with SMTP id o26so3124856lfc.10 for ; Thu, 04 Jan 2018 13:10:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=CU+qjwDkrK4IKq8ftxS3PIcHBrUIZPyxmHiptuOufng=; b=l7/58HChMDDs8syC/pWvd/ufBaua+VaNUxfWXTPeHVTg87W9mc6sZPMqS8LFYlIoxc 8lXWZrynPqyzJ1iK4KNdZdqHwPwsUiF1QNb5kkJ+Wd6NyVMddC+ZZQeOT1qAloDz6I4j Ih3wI0JPsiPqw43IFLt+4paakqkzU/t+BwmPE+MDaagcTl0v9t/u+gCOEabzFv25ayvp ZdPBx8T+6cKrQbisyUm/6Y9em/t7Zm8Wa6/mtfHxjrs2SafLjcdwQDAqoUF8lITMCJQs 1xM3GuzGrdsEG9gWEhNYOfqDHlBYOScNdQyi6aIFvBlIMvsLEJFtu9hrPIZ/oNJzMnlI hI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=CU+qjwDkrK4IKq8ftxS3PIcHBrUIZPyxmHiptuOufng=; b=CAOLW2FyDNz8W3v/XWLQV8x8XrheGh63Am74OJwoIaZSTrrHv9QeaR9Jhuug/kNNrC Mm5MA4Mdu9UHkXKzXgx+SyBQOc/2NwKLomREYpaySGB2UpiaOIZybwxS5lcnxBEpye5J slTB/WkfYWqSLWligLJK/6u9QUvysLrMaQzguPIjqdm/RR32OP/DoedSG6xqgozBpfS3 5OlNLCNyt3sACXawfi83XxBheMr9qb8gMy+NUH0mOeyM16WFg9KOWiGSBwyLmhj13dyK RgRE8ebcAFEdzG4xtzyfc5EWQJVUDGU5znTL6y+I6N8q4l6QN36X2RRRDy1H344pcK/2 W5pw== X-Gm-Message-State: AKGB3mIfElMWPbM2hq5GsddPAunx8SrXLbmzJ6CqKSyVW1YPXaJXf2Yd iGttUq/8nBjv8Ivz6QATNlTNLgqU X-Google-Smtp-Source: ACJfBosyQ+iwfiNrNPKCk/L0G07up3cCUrab/Qh7kc1MNQy/NY0rKAaNaOZevTonFUHjM58Of2e5vA== X-Received: by 10.46.25.80 with SMTP id p77mr424518lje.31.1515100196858; Thu, 04 Jan 2018 13:09:56 -0800 (PST) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com. [209.85.215.54]) by smtp.googlemail.com with ESMTPSA id h98sm768336lfi.48.2018.01.04.13.09.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jan 2018 13:09:55 -0800 (PST) Received: by mail-lf0-f54.google.com with SMTP id o26so3124713lfc.10 for ; Thu, 04 Jan 2018 13:09:54 -0800 (PST) X-Received: by 10.46.16.149 with SMTP id 21mr459694ljq.119.1515100194083; Thu, 04 Jan 2018 13:09:54 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.201.210 with HTTP; Thu, 4 Jan 2018 13:09:33 -0800 (PST) In-Reply-To: <9a3a8760-f65a-a5c0-b318-1830a9a986c3@gmail.com> References: <9a3a8760-f65a-a5c0-b318-1830a9a986c3@gmail.com> Date: Thu, 4 Jan 2018 22:09:33 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Strong Typing Syntax From: andreas@dqxtech.net (Andreas Hennings) On 3 January 2018 at 21:26, Rowan Collins wrote: > Hi Michael, > > On 02/01/2018 10:35, Michael Morris wrote: >> >> I would like to propose a clean way to add some strong typing to PHP in = a >> manner that is almost fully backward compatible (there is a behavior >> change >> with PHP 7 type declarations). As I don't have access to the add RFC's t= o >> the wiki I'll place this here. > > > Thanks for putting this together. Perhaps unlike Andreas, I think it is g= ood > to look at typing changes as a unified framework, rather than considering > "typed properties", "typed variables", etc, as separate concerns. If we > don't, there is a real risk we'll end up making decisions now that hobble= us > for future changes, or over-complicating things in one area because we're > not yet ready to make changes in another. I think the best strategy is to develop a greater vision of where we want to go, and then identify manageably small steps that move us in this direction, and that do not create conflicts in the future. This means we are both right. I still think the following are good "small steps": - typed properties with type lock - typed local variables with type lock - discussion whether and when parameters should be type-locked in the function body. Of course there should be consistency between those steps. You are right, we also need to consider when these types should be validated, and/or how the variables would be implemented. Perhaps we could actually create a system where type-locked variables use less memory, because they no longer need to store the type of the variable? E.g. a type-locked integer would only use the 64 bit or whichever size we currently use to store the actual number. > The biggest issue with any proposal, though, is going to be performance. = I don't think this is an incidental detail to be dealt with later, it is a = fundamental issue with the way type hints in PHP have evolved. PHP is extre= mely unusual, if not unique, in exclusively enforcing type constraints at r= untime. Other languages with "gradual typing" such as Python, Hack, and Dar= t, use the annotations only in separate static analysers and/or when a runt= ime debug flag is set (similar to enabling assertions). A system where all variables are type-locked could in fact be faster than a system with dynamically typed variables. Depends on the implementation, of course. I imagine it would be a lot of work to get there.