Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102169 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32615 invoked from network); 5 Jun 2018 15:04:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2018 15:04:41 -0000 Authentication-Results: pb1.pair.com header.from=theodorejb@outlook.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theodorejb@outlook.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain outlook.com designates 40.92.8.50 as permitted sender) X-PHP-List-Original-Sender: theodorejb@outlook.com X-Host-Fingerprint: 40.92.8.50 mail-oln040092008050.outbound.protection.outlook.com Received: from [40.92.8.50] ([40.92.8.50:45501] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/5F-62758-686A61B5 for ; Tue, 05 Jun 2018 11:04:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uF0bXTYLbqYh8EVNtfjF1WbSLfj5bfTe37PhvXX6RK8=; b=qKwFuajYvcKgggJxrOlgyc/V0FuQnlCM+NBL0tLN4V869pKOFhUQhqQ2CPH+RKHydLfGoVbF/mhtmjFUFzjCdIP/nqeSbHajEu78dIjnJSVeSeor5/gHltWwpj4OIWuOcgiQS4yn//ivpTOQrpAaQ07K/I/50PdMhn6jUlpVVvYfwROKyWDybvPrHIBFDj/pEsaB2GlXnLdhA1+LjGNUmGv6KGxcwT7y+uwT2dZVup25/65XdiVLAZifnUGypjiKj04j2CpqomI1iE75vL9VWx49tiEXqZGnZ6n7cXNOfX586xGVK+Gm3u+QLDmIBZmAN02fwgjaYDr8e0L0f1A+iw== Received: from CO1NAM03FT038.eop-NAM03.prod.protection.outlook.com (10.152.80.60) by CO1NAM03HT139.eop-NAM03.prod.protection.outlook.com (10.152.81.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.755.15; Tue, 5 Jun 2018 15:04:36 +0000 Received: from CY4PR18MB1048.namprd18.prod.outlook.com (10.152.80.54) by CO1NAM03FT038.mail.protection.outlook.com (10.152.81.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.841.10 via Frontend Transport; Tue, 5 Jun 2018 15:04:35 +0000 Received: from CY4PR18MB1048.namprd18.prod.outlook.com ([fe80::24e5:411b:13c1:151f]) by CY4PR18MB1048.namprd18.prod.outlook.com ([fe80::24e5:411b:13c1:151f%12]) with mapi id 15.20.0820.015; Tue, 5 Jun 2018 15:04:35 +0000 To: Yasuo Ohgaki , "r.gottesheim@loot.at" CC: PHP internals Thread-Topic: [PHP-DEV] Better types without runtime checking Thread-Index: AQHT/J3+4sRxhjr3qUKGBp5XwDSzXKRRRG2AgABoIkc= Date: Tue, 5 Jun 2018 15:04:35 +0000 Message-ID: References: <0d108361-f5fa-fe76-b6ad-66e23bfa88f5@loot.at>, In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1CDC1AEBCF4C0D42060609C06E9F86AD38958AEB335422804E4CA821939804A2;UpperCasedChecksum:138FAF41276640CAB054232BE504D970C4D5C845C8DC3D205D6CF7CC06EA2E84;SizeAsReceived:7199;Count:47 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [lEFdvvQqtgEekKj+SlpihMan+YTtAlUJ] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CO1NAM03HT139;7:qoESrGuGiO3REKbE0s1V/uHMBAErfMiC5yx8ahARJtycCAuYKCncdI8ctO6fjvhTYsy0/Ly1h+jxMLNx4v9agbuOed49UiUljUfrENwrLbeoaLpfQOcXkoxI+IcP6ov5CNbc8m9KQHsaqaNb37eJAVMiHXzpH/d9Vv8+Cci/7DecyUTKkPUPyd5tOA6eBUchzmhqO39pRWHaAIy8QzJF82yOCleb9osrjnkiDMhTR5SLPBQhi+uvAxCqmpI8yKyP x-incomingheadercount: 47 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125466)(1701031045);SRVR:CO1NAM03HT139; x-ms-traffictypediagnostic: CO1NAM03HT139: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(444000031);SRVR:CO1NAM03HT139;BCL:0;PCL:0;RULEID:;SRVR:CO1NAM03HT139; x-forefront-prvs: 0694C54398 x-forefront-antispam-report: SFV:NSPM;SFS:(7070007)(199004)(189003)(486006)(8676002)(33656002)(14454004)(305945005)(110136005)(82202002)(229853002)(76176011)(26005)(87572001)(25786009)(5250100002)(2900100001)(106356001)(7696005)(81156014)(8936002)(102836004)(6346003)(68736007)(4326008)(55016002)(97736004)(104016004)(426003)(5660300001)(2501003)(476003)(3280700002)(74316002)(6436002)(11346002)(6246003)(105586002)(86362001)(3660700001)(53546011)(20460500001)(99286004)(446003);DIR:OUT;SFP:1901;SCL:1;SRVR:CO1NAM03HT139;H:CY4PR18MB1048.namprd18.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=theodorejb@outlook.com; x-microsoft-antispam-message-info: 2h397xorsoyeuH3Giq4B1tgA9MrLIeaztiZNGB59epcs1XSgSa5f6qEv4up9rm5rrckFynmzcFp66YNxuFpDTrxgbVA+kWhC0PeoXjnb7zUHOCLTFn+UJuzAnBTY7HAbtTntfoUFP79XWHGjMRKiiI3wwMTwRZQAxxAkk5Y6+u77tt2PXsgXSuH96UXxDS6M Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 79378be5-23c5-46f4-3108-08d5caf5a6df X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: dd759f05-a917-4aa0-a2f5-4cc35c50e0c8 X-MS-Exchange-CrossTenant-Network-Message-Id: 79378be5-23c5-46f4-3108-08d5caf5a6df X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: dd759f05-a917-4aa0-a2f5-4cc35c50e0c8 X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2018 15:04:35.7535 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM03HT139 Subject: Re: [PHP-DEV] Better types without runtime checking From: theodorejb@outlook.com (Theodore Brown) One Tue, Jun 5, 2018 at 2:28 AM Yasuo Ohgaki wrote:=0A= =0A= > On Tue, Jun 5, 2018 at 4:23 PM Rudolph Gottesheim = =0A= > wrote:=0A= >=0A= >> There's always a lot of talk about types in the PHP community.=0A= >> Specifically, many developers want property types, generics, function=0A= >> signature types, union and intersection types, and more. Those talks=0A= >> (and RFCs) always end with the same result: "We can't do it because=0A= >> performance issues."=0A= >>=0A= >> Has there ever been a discussion about adding some of those features=0A= >> syntactically, but ignoring them during runtime? At least until someone= =0A= >> finds a performant way to check them at runtime. That way we could have= =0A= >> advanced type checking in our editors at least.=0A= >>=0A= >> The idea will sound familiar to TypeScript users. It works great for=0A= >> that language.=0A= >>=0A= >> I'm excited to hear your opinions.=0A= >=0A= > DbC style has no performance issue at all. In addition, you can perform= =0A= > much better validation than simple type checks.=0A= >=0A= > function f($username) {=0A= > assert(is_string($username) && preg_match('\\A[a-z]\\z', $username);=0A= > ....=0A= > }=0A= =0A= Assertions are not a replacement for syntactical type declarations, since= =0A= they cannot be checked until runtime. They are also more verbose, and=0A= don't help editors provide autocompletion when writing code.=0A= =0A= +1 to the possibility of a PHP static type checker which can be run=0A= independently from the runtime to support more advanced types without=0A= degrading performance.=