Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94897 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71574 invoked from network); 7 Aug 2016 11:29:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2016 11:29:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.179 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.179 mail-yw0-f179.google.com Received: from [209.85.161.179] ([209.85.161.179:35751] helo=mail-yw0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/01-33134-6AB17A75 for ; Sun, 07 Aug 2016 07:29:42 -0400 Received: by mail-yw0-f179.google.com with SMTP id j12so290055302ywb.2 for ; Sun, 07 Aug 2016 04:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=R3pzWjulPKsp71m6oqzi+mrnxVdWAf60B+f19WtjCKQ=; b=nGbMQV3Qzn/Q2s4FrN5BLY/+aK+0VmJ9fSCDJZ/VmI9JbYq5HT7vQl+erBmz2ri8Ra IrbAV4neDzeQtPwoBJ/ckEfC9cHs90URKceP3b/9v/8ZNOzAiGP3iERZ8f96j1dONznN Tiow3DMN4kB5fYTj5KAzdtvKWmzzx29Cadnb+AEkUUxEZysBvaMINSgAEQ7igJYcBJEn ztH8gAkU3Ib16+fT+3ptlAgJzfmSU6ajOAu4n+CzZyywd8nn4sRc8NOQhSttJThj7T44 MdV7cNc+bs+6ZUhbkKzi4ZZhWWHhcFOfKQkZXQbGGFYgaaIdFT++1T/n/vp+xAdAIIt5 lzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=R3pzWjulPKsp71m6oqzi+mrnxVdWAf60B+f19WtjCKQ=; b=crGwpeFJ7ej3HQzHDXUGoRDCq1qhKKsatP15RvqfG4Z4maqT/+MQWO8E07QcjxVsy5 YU0rHXnDy0rNc457UMFdmaghDifhQpUOAtYHGauQgT+Dcd4wz7oK4fR++0jgiNvGkNk4 tm6Xz/zHIcAmX1lIHTuNaWSe++VQXzBIL8d+Pgeho/rJR0ypeYS9/4ISBZBD15gVPefh 2qD1JYrHCdyqmkdHr8G8g6wglCveafsS+ThGh0NfaW7gGfynfv0UWldgrkKDx8DpVmg0 xctnrHzfX1U7YgazHYRvpcRdFF9dkCGO5kL8Z6MunlBwqbfD7BFuCK6hUUh3oXNlTwzG xs4A== X-Gm-Message-State: AEkoouvOtymiI2RcyW0Jl+XZ0z2DJIErr3zW4AT1rnXNtPE7dYGzoOHRkzPg+SfrS/FvRMth+2tmFkkU397oBQ== X-Received: by 10.13.206.3 with SMTP id q3mr68048221ywd.139.1470569379644; Sun, 07 Aug 2016 04:29:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.131.129 with HTTP; Sun, 7 Aug 2016 04:29:39 -0700 (PDT) In-Reply-To: References: Date: Sun, 7 Aug 2016 13:29:39 +0200 Message-ID: To: Rasmus Schultz Cc: PHP internals Content-Type: multipart/alternative; boundary=001a114dbd547dcc080539799d78 Subject: Re: [PHP-DEV] Function auto-loading From: nikita.ppv@gmail.com (Nikita Popov) --001a114dbd547dcc080539799d78 Content-Type: text/plain; charset=UTF-8 On Sun, Aug 7, 2016 at 1:19 PM, Rasmus Schultz wrote: > I'd really like to see the function auto-loading proposal revived and/or > possibly simplified. > > The fact that functions are hard (in some cases impossible) to reach by > manually issuing require/include statements is, in my opinion, half the > difficulty, and a much more deeply rooted language problem exacerbating > what should be trivial problems - e.g. install a Composer package, import > (use) and call the functions. > > Looks like a fair amount of work and discussion was done in 2013 on this > RFC: > > https://wiki.php.net/rfc/function_autoloading > > There was a (now stale) proof of concept implementation for the parent RFC > as well: > > https://wiki.php.net/rfc/function_autoloading2 > > What happened? > > It looks like the discussion stalled mostly over some concerns, including > reservations about performance, which were already disproved? > > One issue apparently was left unaddressed, that of whether a call to an > undefined function should generate an auto-load call to a namespaced or > global function - I think this would not be difficult to address: trigger > auto-loading of the namespaced function first, check if it was loaded, and > if not, trigger auto-loading of the global function. I feel like the problem here did not get across properly. Calling the autoloader if a global function with the name exists will totally kill performance. This means that every call to strpos() or any of the other functions in the PHP standard library will have to go through the autoloader first, unless people use fully qualified names (which, currently, they don't). This is completely out of the question. (The case where neither the namespaced nor the global function exists is not the problem. In that case calling the autoloader for the namespaced and non-namespaced names in sequence is of course unproblematic.) Nikita > Most likely a PSR > along with Composer auto-loading features will favor a best practice of > shipping packages with namespaced functions only, so the performance > implications of checking twice would be negligible in practice. > > Being basically unable to ship or consume purely functional packages leaves > the functional side of the language largely an unused historical artifact, > which is sad. Keeping things functional and stateless often lead to more > predictable and obvious code - I think the absence of good support for > functions encourages a lot of over-engineering, e.g. developers > automatically making everything a class, not as a design choice, for the > sole reason of being able to ship and reuse what should be simple > functions. > > This RFC looks pretty solid to me. > > What will it take to get this rolling again? > --001a114dbd547dcc080539799d78--