Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103395 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 57675 invoked from network); 26 Oct 2018 19:52:51 -0000 Received: from unknown (HELO mail-it1-f173.google.com) (209.85.166.173) by pb1.pair.com with SMTP; 26 Oct 2018 19:52:50 -0000 Received: by mail-it1-f173.google.com with SMTP id k206-v6so2144439ite.0 for ; Fri, 26 Oct 2018 09:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=W0NrUuwba1Kx64eo+S1MbMBYyhPh27LO9r86zJeGrVY=; b=aUWxlNoX0Yx4CJDAC+jN2b7Ezbmw3nPqQcjoyFAdnLzgO/GG7JSRpDVRkcTjranoPA nCSUo1zIn4K40d6CSzCldoQmcuK+cbk5EsPpK0vWG8KbMkDp1gAFtLTKscqFeLjVjiUs 2DAnvjEIdGIoUWjwjwoVtnguw7hr3tVD1yTt+HzIKvDiai1wp/uZFpybM6+0965+3y4T DNUSi1BM5ItLHIjYIskSmmpkYrYpRE4I1Ni9/eHdvh4Xpy0JoaclIdOtXc6e9KbFxqw3 NOH6aA2oiIM7LfJZsXuJhW0LHkUd4/HFKvdNNNBeLCvpJZbnUEcY4qjXXJysfcm2Wjsc hMdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=W0NrUuwba1Kx64eo+S1MbMBYyhPh27LO9r86zJeGrVY=; b=sqdK04ICH+RbwbpSHa6Okeqk2wWCVblyIwhSUC1OM6H8DNXSBG9tnK9oMQo1uB9/bL CXdF1dxqujb9C16KAU/4Cw5oXWoUK8dYrKjsGOSHGc0YZl91UFXt2s2te7lKAY9AIv9i 08PHUA9S/algcbJwQDJdnU1yHJ/Y9K8w8n3IFi6OQRfregWBDTnkOl4tqrRsmsh1jrvs QYIhyq7kumHAU2auJTrM8w3SFbuvx580O4IEo1YYJfYTl7gPUGwVfSi5C1qvF34OVw4e q37xlx9+WlCu4gha431FL8tQsDKzjyJFPKGUZZ+45i5hMFurdF2THsxGCwp1VNCLOLgv pheQ== X-Gm-Message-State: AGRZ1gLkB4wTUmg+4x8jg/2pZ+fJYmnDz0sFh7VCDXS/Tfo6Tzr2Yzcv fhwonZ/AWFC3ph4IVaDwBaPVCwI1478aKlq5Btk= X-Google-Smtp-Source: AJdET5cLz2ViJKlh83m7mWwsVVvuh+57mHpexlhsfZrEnTphTP1faSXd1V4xseQVqvSEnyXJu+PPMLBynY0LVzS74FY= X-Received: by 2002:a24:5452:: with SMTP id t79-v6mr4082369ita.144.1540570109187; Fri, 26 Oct 2018 09:08:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 26 Oct 2018 13:08:18 -0300 Message-ID: To: crocodile2u@gmail.com Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000001c1cdf057923ee8f" Subject: Re: [PHP-DEV] Idea for better function callbacks (another syntactic sugar) From: david.proweb@gmail.com (David Rodrigues) --0000000000001c1cdf057923ee8f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Em sex, 26 de out de 2018 =C3=A0s 09:30, Crocodile escreveu: > Hi internals! > > I have this idea of improving the way to specify callbacks for good old P= HP > functions. For instance, I have this piece of code: > > --------------- > array_filter($names, 'trim') > --------------- > > The callback function name is specified as a string, which makes it > not-so-obvious, although this is definitely a PHP way. An alternative wou= ld > be to rewrite this using a lambda: > > --------------- > array_filter($names, function($name) { return trim($name); }) > --------------- > > This is way more wordy, and I bet most of us will go for the first option= . > > What if we had a more clear way of specifying those callbacks? I suggest > the following: > > --------------- > array_filter($names, function::trim) > --------------- > And about methods? How it should works if I wants to call a method from a custom class? It should be function::CustomClass::someMethod? > > It is, I believe, more clear then a simple string, just a bit more wordy, > and since "function" is a reserved word which never had anything to do wi= th > "::", the lexer/parser could probably find a way to deal with this kind o= f > syntax (well, honestly, this part is totally unclear for me because I onl= y > work with PHP from userland). > > Does anyone else find this could be a good addition? Or is it not worth > considering? Or maybe I am missing some obvious pitfalls? > > Cheers, > Victor > -- > Best regards, > Victor Bolshov > --=20 David Rodrigues --0000000000001c1cdf057923ee8f--