Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94957 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38339 invoked from network); 8 Aug 2016 22:00:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2016 22:00:00 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.217.180 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.217.180 mail-ua0-f180.google.com Received: from [209.85.217.180] ([209.85.217.180:34222] helo=mail-ua0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/4B-33134-FD009A75 for ; Mon, 08 Aug 2016 18:00:00 -0400 Received: by mail-ua0-f180.google.com with SMTP id 35so274924203uap.1 for ; Mon, 08 Aug 2016 14:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MTQqM5TacwvFz/JVeFXWX83KOIfFPvJTuagKTjoikoI=; b=SExcBP2bhhMuzYs5mZ6h00IxoMrgod9Vg0P+I8h/FgEjYMt/Dm85fmbpJ68ogkj7nU ZmEuXzkZVXlN9gDubT41TAxIzyCU61OoidueMdEAQLTQf97nQyZyLoJ9rRs++8qSsurK cTGPlp+bmlvdFESzhGww86OKBWmfqSJwkjJJupF5DStImuax2gNl5omJ9GoMq4+l00yf 0W6v8Iv8Eln+uwsoXXrpNjwnvWpHoCHyoRiI1tBAu2qBB+9BTBjWlsH8pMNoQ+QvMlEE wgYmCBba/9SnDHm89SZe3eytWa0SMoJn46PO3qJXIchRYSJdh6QAUDKwWGNERZV91Dhe wQRw== 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=MTQqM5TacwvFz/JVeFXWX83KOIfFPvJTuagKTjoikoI=; b=SXqOEY7a4DCfPmvXNymmm83VrtvN27n8/udV1jACPxfg9Rtz0mGw1C70fiq/5mm6XS kRjnmFhlxgFfEGwebVXeGRMD5ziwmn7s9OtzUyB4vt8LIVCjDS7exX3lbUJ5ul1orwXO /zaoV3IaVmr+nWUoxyD6Dew/Jna2Bsxd6PIPVa0Ii/129d4t/Mlx1oSKEdGw8K0MSnSf v3VVJV+otAj43frTMbK81gmF4s+zcRSjY15JGv2NTIWmZnu1pOl5zUMtsor8+SCaWTBL ob9aWooJbdoN8JOosoGWD+/06aD8VEHC/YeV6kHduGRcjf9mrbW3ajX/501iIg6Tjbmo INBg== X-Gm-Message-State: AEkoousmalG60nk2PXmNqNSGU6wv4WARqtj40HMqGw/y939Irx20Nxl/hX13Ov71lC1LAkkZa75vyEr97NUtqg== X-Received: by 10.159.41.164 with SMTP id s33mr48504316uas.146.1470693596728; Mon, 08 Aug 2016 14:59:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.153.195 with HTTP; Mon, 8 Aug 2016 14:59:55 -0700 (PDT) In-Reply-To: References: Date: Mon, 8 Aug 2016 23:59:55 +0200 Message-ID: To: Lester Caine Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Function auto-loading From: rasmus@mindplay.dk (Rasmus Schultz) On Mon, Aug 8, 2016 at 10:54 PM, Lester Caine wrote: > I can understand a little the overwhelming desire to wrap everything in > it's own set of name spaces, but is that REALLY essential to make PHP > 'work better'. What is wrong with a simple 'include_once' of the library > you want to use globally across all the code? Doesn't work with Composer packages, because you can't (and aren't supposed to) know where a package is installed. That is, when I'm running the test-suite of my package, the Composer project is the root folder of that package - but when the package is being consumed by another project, it's installed in a sub-folder in that project's "vendor" folder. The whole point of auto-loading is you don't need to know where things are installed - a class will simply auto-load, regardless of whether or not the package is the root project package of the consuming package. Composer takes care of the bootstrapping. If we didn't care about that, we wouldn't need auto-loading at all. Or in other words, your argument works against auto-loading of functions and classes equally. What's wrong with a simple require/include statement when you need a class? Nothing per se. It's horribly inconvenient. The main reason you're not feeling the same inconvenience when it comes to functions, is likely because you avoid using them - which is likely because using functions isn't practical. Likely because they don't auto-load, like functions. So we use classes as pseudo-namespaces, because they can auto-load - but that's not what classes are for; you could just as well argue the language shouldn't have functions at all, then. In a nut-shell: functions are inconvenient because they don't auto-load, so we don't use functions, so we don't need auto-loading; but that's a circular argument. Of course we need functions to auto-load. For all the same reasons we need classes to auto-load. Nobody wants to stop and have to figure out in which file a function is located before they can call it, anymore than they want to do so for classes. Nobody wants breaking changes in 50 different files because they renamed a file or decided to split/join some functions across some files. The auto-loading requirement for functions is the same as for classes. There's no difference.