Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98009 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72750 invoked from network); 28 Jan 2017 20:17:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2017 20:17:33 -0000 Authentication-Results: pb1.pair.com header.from=netmo.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=netmo.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.180 as permitted sender) X-PHP-List-Original-Sender: netmo.php@gmail.com X-Host-Fingerprint: 209.85.161.180 mail-yw0-f180.google.com Received: from [209.85.161.180] ([209.85.161.180:35989] helo=mail-yw0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/00-06271-B5CFC885 for ; Sat, 28 Jan 2017 15:17:32 -0500 Received: by mail-yw0-f180.google.com with SMTP id v200so36116378ywc.3 for ; Sat, 28 Jan 2017 12:17:31 -0800 (PST) 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; bh=ZwJhLAYcR+sYpR/hP7xUXrrkTQShf+l/U9C5dLI/8C0=; b=YGO0WbiUU8pvDsQVXtoS6vyPG5CeRTquc8efbqDHJpLjFHbg89p02lFnH3H4Oyc4Vl ThtNKtOwRb3yxlLfzumMBiyKSDXl8FypcIG1F0RN3xpTDk295R1pkSEEe1JIJ9x2euNH t9Ot/J/Sylyw1RqL86uYEG4Ytkc5Lbgkje7mIAdFQK6a2nGhoKMevGxTy6MvzeKevSCk flz6Z2BBh2ku2lwR2zgyOT2W4XyKuCU3m2Ltb6kgWFkgl8pHihAoZ+209PG7yizaLkAD hY3H4OzI+ai9pvTEONC6y/WvmFiK1TsgA71TNVdSudaY+AR8KP8H5clTwxoIHEYY53Gi 7xAA== 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; bh=ZwJhLAYcR+sYpR/hP7xUXrrkTQShf+l/U9C5dLI/8C0=; b=WNSr6xwqJBzRgSbK4WC4pHG2BGBnEDmQCWSFRbnTk1plL9j/3t6V9vfVi/NZwQWNMa I+8LC+ME6xxFvAKgvXt3RqvnHMKLM0xlY6lJHZjyifrosozRPK/Uuu7+reK260162jHN tVirmxFgF5M7sQ9b8UDYzLO8MkJiVCoVnX29b74PKwSBRNhc7nNNpkvvG2/1J2RtWHPf qAU9+h424s3oI25Q6cFOKsNeeIglcQ53rzZY1PmEBNrVRVtOTU+hmd/NP4tz8Qhjf5uo B7j1RdCvh966R7KeQc8Vqs0kALBo36cXKnnFL0U2Yw3N+iK0k8KwIQ9GTCFrf+wS8M7H zzAg== X-Gm-Message-State: AIkVDXJyYcjfgrAoTRgCGj1Hx7UcMVTwkzuLoVxmSaGGpgMI7D48P08J8NW4vvkilqOlrq0wFyl/HDF3Ymj1RA== X-Received: by 10.129.156.87 with SMTP id t84mr11310064ywg.100.1485634648988; Sat, 28 Jan 2017 12:17:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.128.71 with HTTP; Sat, 28 Jan 2017 12:17:28 -0800 (PST) In-Reply-To: References: <9113D065-B94A-4CA2-9420-56963C703ECA@gmail.com> Date: Sat, 28 Jan 2017 21:17:28 +0100 Message-ID: To: Rasmus Schultz Cc: Rowan Collins , PHP Internals Content-Type: multipart/alternative; boundary=94eb2c0b7b0084e66005472d4560 Subject: Re: [PHP-DEV] Not autoloading functions From: netmo.php@gmail.com (Wes) --94eb2c0b7b0084e66005472d4560 Content-Type: text/plain; charset=UTF-8 > > old applications could maintain compatibility only > > by adding a simple autoloader that would alias the global > function/constant > > into the calling namespace > > So as a side-effect of calling any function, my namespace would get > polluted with all sorts of random names? That sounds like a messy > work-around. > > Obviously it would be just a temporary workaround. > Okay, so take it back for a moment. > > The problem case is this, right? > > namespace Foo; > bar(); > > If the function Foo\bar() has not already been loaded, we fall back to > bar() in the global namespace. > > With a function-autoloader in place, we would need to trigger this for > every function-call from any namespace, and that's unacceptable. > I'm sorry, it's unacceptable for who? Only for not defined function it would be called. If I call the same function a thousand times, the autoload will be attempted just the first time, and if it doesn't work then the script would die, exactly like classes. Any project I know that uses functions define them one per file, and each file is required one by one. How is that different? Plus, there's opcache: function autoloading is not really autoloading but actually about "not having to maintain lists of require()s". Also, if you really think having one function per file is too much, you can always require everything in one go: ``` function autoloadFunction($functionFQN){ // $functionFQN = "\\foo\\bar\\functionName"; $namespace = substr($functionFQN, 0, strrpos($functionFQN, '\\')); require($namespace . '\\all_the_functions_and_constants.php'); } ``` > So what if, instead of trying to autoload everything by default, we make > it opt-in? Something like: > People clearly need this and I wouldn't mind if this was the solution. But, this is a workaround imho, and contrarily to what I've suggested, this wouldn't be temporary. --94eb2c0b7b0084e66005472d4560--