Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105340 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91418 invoked from network); 23 Apr 2019 03:50:20 -0000 Received: from unknown (HELO mail-40133.protonmail.ch) (185.70.40.133) by pb1.pair.com with SMTP; 23 Apr 2019 03:50:20 -0000 Date: Tue, 23 Apr 2019 00:50:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=default; t=1555980635; bh=fp8jNBxRgnXbJ8cQBGX77bVjxuD6B+XXLZD1rV8/Khc=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References: Feedback-ID:From; b=jAByvz/64LRl3UuB208G6xC7Adae+QYEt/BfPncke1mP73+aGBTToKCT9xTKIOuOs o/zQ93yxrqgLqw7IqkKc7I5n8MRapuuyyOWz2tXnIbWDxLOmXksLEY/PT4SRzTbNIP Pv/dw51Vj3+d8S4SIAF8OHW2iKIVXEtiEMkZz99Y= To: Stephen Reay Cc: Benjamin Morel , Larry Garfield , "internals@lists.php.net" Reply-To: azjezz Message-ID: In-Reply-To: References: Feedback-ID: 2QbNVvXqZX7F9J8FTDAv0u3ryua4T0_lfklxZ8hRMzvBUxf8m8U50Gi9tVWG9V2LePU31MFOrVnxPKYLJjZPXw==:Ext:ProtonMail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch Subject: Re: [PHP-DEV] Object Type Casting Reloaded From: azjezz@protonmail.com (azjezz) I think we would be talking about typed variables at that point. ( something you can do with PHP 7.4 http://github.com/azjezz/typed ) even though `as` is used with `foreach`, i don't think it would be an issue= to use it for something else, but i think i will leave that to someone who= 's more familiar with the PHP parser than me. Cheers. Sent with ProtonMail Secure Email. =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Tuesday, April 23, 2019 1:43 AM, Stephen Reay = wrote: > > On 23 Apr 2019, at 06:30, azjezz azjezz@protonmail.com wrote: > > Hello Ben. > > yes, i have made a gist with a simple example to show the `as` operator= usage in hack + HHVM ( 4.1.0 ) output. > > see : https://gist.github.com/azjezz/03955ff2b009f1ced22ce68c9a862847 > > Sent with ProtonMail Secure Email. > > =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Origina= l Message =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80= =90 > > > > > On Monday, April 22, 2019 11:50 PM, Benjamin Morel benjamin.morel@gma= il.com wrote: > > > Hi Azjezz, thanks for jumping in! > > > > > > > I have been using HackLang for quite a while now and i believe they= have a better solution for this, and it would awesome to see it in PHP, th= e `as` operator. > > > > > > If I understand correctly, `as` is an operator that performs type che= cks but never casts like () does. > > > This looks like a serious candidate for an alternative syntax to the = one I proposed! > > > > > > - Ben > > I like the idea but I find the syntax (both suggestions) less than great,= given that there=E2=80=99s already =E2=80=9Censure a type=E2=80=9D syntax,= and both suggestions are already used for other things (casting and foreac= h) > > Is there some reason (eg ambiguities) a type can=E2=80=99t just be placed= before a variable to ensure a type, similar to a function parameter or typ= ed property? > > Eg > > string $foo =3D 'bar'; > array $bar =3D getBar(); > foreach($bar as int $k =3D> string $v) {...} > > Cheers > > Stephen