Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114606 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39329 invoked from network); 26 May 2021 05:32:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 May 2021 05:32:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B6AB1804D9 for ; Tue, 25 May 2021 22:44:23 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 May 2021 22:44:23 -0700 (PDT) Received: by mail-ua1-f43.google.com with SMTP id n61so134931uan.2 for ; Tue, 25 May 2021 22:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=h++mF3DjkrqtRTcUcEbssd9Q5opcz0a6DG50e3UeM9w=; b=iM7RGmMLe3MSwKbEavaYMXMV22QKHpk7AucBUUJKPx6iGJ9Sta9jQkpaXk0SyXPw7O cpwpJoeifvVUqJoANtvepa8h/wcu44AIAcNHdSIWsiSoUCN1c+4CoGpPlW3Bg1J6b5wc M+Iax8FhlJ4NP1cB/lKsiRuSSOESWsGf++z5SyFLKD+FsxsVQJ11HaP33YOiQkrFQABa e4C6Esj7GT6IHXILFEbZ1dLFkdnf+Cc6VKYL8TtYVN8LS3xY/7h3V7aTVry57QNnYlG2 jMicckiKXDjl23yBwKrv3UCTwSxdTTZW0OMnU2JXrSdYlavbclIV3RKSphN/ScI2QPVx HcAg== 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=h++mF3DjkrqtRTcUcEbssd9Q5opcz0a6DG50e3UeM9w=; b=IoR1sZidseTtbUz7ijmAYMm7vB4cbS2p7Y0A47ZoZS+YYMsrU3FW9Nxyu5YPmeJsqa PkGBfX/Ojx7KPJUUIbdElimYB+96oesX54tfrTSIOi4MMdsKSeNkqBo85dD907tZqajP Xd6EJsFwjSd1IDj3T/AxzKTarWM7td1gUUwYeiFhOxtC9JfBWTkWM2K8fm4EnjzAfz/b b1oW8IrMvdIAD9Fi3JfElcdgfGj2aL48/dSgxTvy3Gq3x3ezaNiIr3Hn8umJc/ry7vqM nZp5cyca2xjxUCSAiBhGUKoey6HazjGXUbA1DQqDro2w8stJBbTjpQHoQ9YDmb7E3NFK QBWA== X-Gm-Message-State: AOAM530y47aIF36AiTZl2Pk5r8R6yNenDBNngkESHEG1oj/5/zkbeTyl r9LDcE8Vnn8b4q/GLeoJ289eNPHwgVyt7J+JBAo= X-Google-Smtp-Source: ABdhPJzdZcuaFDnD1+lOENjjFcuyJiNic2iqH24UPBs0VRCAIqm7P3rqCgEBnBOgZ4KA8ekLCFMd+3/W4K1+5yRZDLU= X-Received: by 2002:ab0:3b8b:: with SMTP id p11mr31422012uaw.112.1622007861587; Tue, 25 May 2021 22:44:21 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:2613:0:0:0:0:0 with HTTP; Tue, 25 May 2021 22:44:21 -0700 (PDT) In-Reply-To: References: Date: Wed, 26 May 2021 10:44:21 +0500 Message-ID: To: =?UTF-8?Q?Iv=C3=A1n_Arias?= Cc: someniatko , Hendra Gunawan , Karoly Negyesi , Marco Pivetta , Lynn , "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] A little syntactic sugar on array_* function calls? From: office.hamzaahmad@gmail.com (Hamza Ahmad) Hello, I read about this extension times ago but didn't know whether it had been public. If Nikita is reading this, I request him to think of proposing a modified version of this extension bundled with PHP. In simple words, he can hide the function that registers a class that serves as a prototype of a built-in type. And, also provide with scalar methods for string, int, float and arrays. To get handler registering functionality added to core, there should be a separate RFC. While I read this thread for the first time, I had following suggestions: 1. All array functions should be moved to its scaler object, and the word "array_" should also be removed. 2. To maintain backward compatibility, all array_* functions will become method aliases of scaler array. 3. ArrayObject will also exist for the compatibility purpose, and its methods will also be added to the scaler array. Thus, array() or [] will return scaler array object, and following syntax would become valid: `[1,2,3,4,5,6,7,8,9] -> reverse();` `array(1 =3D> 'a', 2 =3D> 'b') -> flip();` If it happens, users will automatically be stopped from passing non-array values to array functions, and the error will be caught earlier. Regards On 5/26/21, Iv=C3=A1n Arias wrote: > Hi all, > > It sounds like scalar objects by Nikita: > https://github.com/nikic/scalar_objects > > Regards, > Iv=C3=A1n Arias. > > Get Outlook for Android > > ________________________________ > From: Hendra Gunawan > Sent: Tuesday, May 25, 2021 10:58:46 PM > To: someniatko > Cc: Karoly Negyesi ; Marco Pivetta ; > Lynn ; internals@lists.php.net > Subject: Re: [PHP-DEV] A little syntactic sugar on array_* function calls= ? > > Hello. > >> >> ```php >> $array|>map($fn1, ?)|>filter(?, $fn2); >> $array->map($fn1)->filter($fn2); >> ``` >> > > Whitespace removal is not a solution for code length problems. > You might have a new problem if you do it. "|" is very similar > to the lowercase "L" and uppercase "i". > > It's just an extra 3 characters (", ?" or "?, "). For most people, > this is not a problem at all. people tend to write "one statement per lin= e" > rather than "multi statement line". I myself usually write no more than > 3 statements per line if they are less than 120 characters. > > The real problem is there is no consistency for "haystack vs needle" > position. There are RFCs to fix this (along with the naming convention > problem), but none of them are successful. > >> The pipe operator feels like a poor solution while "->" would do >> exactly what people want. > > Not so poor if we > * use "~>" as pipe operator rather than "|>" > * redesign the api under their proper namespace and strictly place > the "haystack" as the first function argument. > > Regards, > Hendra Gunawan. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > >