Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103400 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2848 invoked from network); 26 Oct 2018 23:46:00 -0000 Received: from unknown (HELO mail-ua1-f49.google.com) (209.85.222.49) by pb1.pair.com with SMTP; 26 Oct 2018 23:46:00 -0000 Received: by mail-ua1-f49.google.com with SMTP id o17so806804uad.8 for ; Fri, 26 Oct 2018 13:01:42 -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=BxbQkZNBA9jO8NExd4uP5UfKGTrMRq7JaLEnK6HnjAY=; b=YKkhnS/55MkMyxCX4b5ATeYtVaC7vdw0DBeaaMXAIGgqaSx3lb+gnDIS2xpCSnmUMX 77kusC9N9vHZnOdKYrIbGtsvTmIIGLI6LjICR81ax9CkYDPYGLGT6OndkWnaR7GF9Vtb DHsdJjaUzb7q7ANViNEYksHMRUDLoxGsAU4gc360BrOdqdj+PFo0lFXJLKzTIEPoCkmu Hi5jJomT25IQJka+H2ZzU7qQ9LQmIojdqLDYx9s7/d+Vw5lKoVglu6GwchbrSqBZMd+e h6pYGyNcsSrncPjCcilpMIE45mOwoEXuQbqPWe8HbTjHttjaLw9wR1YdYPsUQneSHyM3 uPjA== 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=BxbQkZNBA9jO8NExd4uP5UfKGTrMRq7JaLEnK6HnjAY=; b=KEj9dfJ9HAyq9+rCsW/+DVDwAOdUXBCH6oK8qhR4Z6o50PU3FsJE14rWCGfORCBc5w avop0AeUVxw1+IMycfyr6s8sLZFd0zvVSvzL/bN0g+PFGGGbrBt/P3WDw6o09q7VBnCw Fj2Xjcgg4xlrAiA0EQYx5Srg5YBIf9r2REGEFDkGZ7ieIdNPuj4zJFUOtHRVD6aUj85T YIrKlYTJM0373O9JxYosUYalohxuIOg2ZYT2sABc82Eb/O3fxg7ZJWzmeuWq4K0dxJ4H usFjV8zaiLci/BvLT2cfiwdOt8I6TQwBsPPgVWkcB96yN5TlzPBF0si7pEkd7SPFXROC /Ohw== X-Gm-Message-State: AGRZ1gKbXK4+jmOcmS5EpyCDfGLdUwQFRYdRubNKnRXJcijbJ7ejXdi1 JYtf92f1MpAg/5jz+BHi8GeqGrQJDl2L/qxtTJQ= X-Google-Smtp-Source: AJdET5cmmKBBFM2HuMNC0obUV4CLLfLwjl+L4Z29aVxtr0GwVvS159ZcBGe14QTo102IAuHuT0lvrWShe7yfjHkWVkg= X-Received: by 2002:ab0:b82:: with SMTP id c2mr2285554uak.121.1540584102061; Fri, 26 Oct 2018 13:01:42 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 26 Oct 2018 22:01:29 +0200 Message-ID: To: David Rodrigues Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000266def057927304a" Subject: Re: [PHP-DEV] Idea for better function callbacks (another syntactic sugar) From: crocodile2u@gmail.com (Crocodile) --000000000000266def057927304a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable My proposal would not work for methods. function::CustomClass::someMethod - that doesn't look great at all, at least to me. On Fri, Oct 26, 2018 at 6:08 PM David Rodrigues wrote: > 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 > PHP > > 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 > would > > 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 sugges= t > > 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 word= y, > > and since "function" is a reserved word which never had anything to do > with > > "::", the lexer/parser could probably find a way to deal with this kind > of > > syntax (well, honestly, this part is totally unclear for me because I > only > > 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 > > > > > -- > David Rodrigues > --=20 Best regards, Victor Bolshov --000000000000266def057927304a--