Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101160 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30416 invoked from network); 27 Nov 2017 14:59:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Nov 2017 14:59:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.216.194 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.216.194 mail-qt0-f194.google.com Received: from [209.85.216.194] ([209.85.216.194:46248] helo=mail-qt0-f194.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/77-26862-1482C1A5 for ; Mon, 27 Nov 2017 09:59:14 -0500 Received: by mail-qt0-f194.google.com with SMTP id r39so39348937qtr.13 for ; Mon, 27 Nov 2017 06:59:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=dpiB6+rC1tmZbPigLWYeZAYo+hAsVUF0Mtb057F/QDk=; b=xBhq9YxkcKE9ERDeTO+xq5aTL2RD7hpuOqjbs7UrhK8UCwWLKI2RTTUku9urNt2+uh HFxp33iGhJkAE/yogyEzY/hjlHOziEYfjngUHiUtA5BkVSSCMP5sngFfBr55X9cNO4D7 IkStt0niEYDwxDkdeZpCioKUGu+VeQ/cqir009dz6E9EtpzcgCgcdMVCrm4I2zHsiPNE fcQZWd0lirS2V3gxvPE2WACBVisiP+162/cQlHI8CN7+9XmP8LIMvCwvMFTBvoV0j3Ix O/5xMkt+8sQpYE8tjkunPso5g0udEeBy/as1PwCt2L/hoToeVqVDgLzo7uFhZeBtW05S ZJAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=dpiB6+rC1tmZbPigLWYeZAYo+hAsVUF0Mtb057F/QDk=; b=NpwNGa0/ePX7I43ec3MeoIVTB9HQH7MCyq0brM6jgdEYKLdPCGNz33FF2jAJQVaoiI qFXDgEvyu35vebe0JQjJ3ilTPseVoM4DfMCWe2/5bg3kRIdOEc74vjKCcbfy4EV40zlU mC1KiS1KC69wcf803bIiwFxk/LjDpWCYcMrNkUH4DB70bQfnX6FhzFM32Klu1ruBoId4 cbDMtNF+Gx3OqXXDdM8/SfVa9pEhRqYIzq0gDIbuRkBHzORKpr9gqInt9+i2M6C9tGrC C9GB5Gkr5Dp6dAMlaecuRbDA4wAriDu4qeCYQcfREknqHRzEKZ5cmvGd19POoBk2g6E/ MbXw== X-Gm-Message-State: AJaThX66RTdKME6OkcxAyvFv7VLLRb3e/r93kgBCj6nhTCv/iHA4oXFT s8pX69aofgs4O1cQpa+BY/Xc+b7Xudo7grsWCSZteQ== X-Google-Smtp-Source: AGs4zMZaybdZeZK4xTZhYuhdJxMvmQllamVqNN67zBnqvBkxk08E7bHITHY5dzjva+gxIxedrDPT7mSxay9hfphq3H0= X-Received: by 10.200.25.207 with SMTP id s15mr58534507qtk.94.1511794750998; Mon, 27 Nov 2017 06:59:10 -0800 (PST) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.12.158.145 with HTTP; Mon, 27 Nov 2017 06:59:10 -0800 (PST) X-Originating-IP: [206.252.215.26] In-Reply-To: References: Date: Mon, 27 Nov 2017 09:59:10 -0500 X-Google-Sender-Auth: EaO2nAwNvmLHtdGDi-8g4dvTV1w Message-ID: To: enclaved@safe-mail.net Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] C++-like function-try-block proposal From: pollita@php.net (Sara Golemon) On Sun, Nov 26, 2017 at 11:06 PM, wrote: > I am proposing a patch (see attachment) > php.net mailing lists don't like attachments (virus paranoia and similar). If you have a patch, the best thing to do is submit it as a PR on github. Then, we can all link to parts and add comments and it's generally a better place to discuss implementation. > to bring C++-like function-try-block > shorthand syntax (http://en.cppreference.com/w/cpp/language/function-try-= block) > for whole-function try-catch-finally blocks: > It's a pretty minor bit of syntactic sugar that I use in C++ occasionally and it can reduce cognitive overhead by some fraction of a percent at the cost of a little extra complexity in the parser and no compiler/runtime changes. Overall I'm only +0 on it as it does add complexity to the parser for a very very tiny benefit. Consider the following already legal syntax: function fuu($foo, $bar): void {try { may_throw($foo); may_throw($bar); } catch (FuuException $e) { echo $e->getMessage(); }} Same effect and very nearly same visual scan as the block you pasted, but with no need for additional syntax. > Since PHP is partially influenced by C++, I believe this syntax would be > a meaningful step in making PHP a little bit more intuitively compatible > with C++ practices, which may prove useful for people who come to PHP fro= m > the C++ world (such as myself.) The expected benefit is PHP becomes yet > more familiar and comfortable for C++ programmers. > I'm not sure this statement is entirely accurate. PHP's fundamental inspirations come from perl and C. It's OOP layer was inspired in part from C++, but also from Java. This mixed ancestry doesn't necessarily indicate a push toward any one of those syntaxes. PHP is PHP, it's best when it steals the parts of other languages which make sense for it to steal. > I submitted my patch via the bugtracker: https://bugs.php.net/bug.php?id= =3D75576 > Ah, disregard my initial comment above then (though PRs do have advantages)= . At a glance, your patch makes sense. =F0=9F=91=8D -Sara