Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:97969 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86755 invoked from network); 26 Jan 2017 10:21:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jan 2017 10:21:42 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.176 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.213.176 mail-yb0-f176.google.com Received: from [209.85.213.176] ([209.85.213.176:36371] helo=mail-yb0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/C1-04124-5BDC9885 for ; Thu, 26 Jan 2017 05:21:41 -0500 Received: by mail-yb0-f176.google.com with SMTP id 123so36421823ybe.3 for ; Thu, 26 Jan 2017 02:21:41 -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=mWTWucCj62ZSQyWeoqHF8QcqQdqXam/8vtN0uJUf2WI=; b=Y+Z87NyDu8GbWGjNRAqQeGj7XaZcR47VcvXyFVtLYU1smZcrpWZkknQQViF+8dYEUP oscp/QUQCV/VR6Lw98SBtzmq5txi0vR4ftIqEDqNA0rrDp5bq4YKWeoPJy8aB/sJvM1S r2ZsrikMpOAaIp5XRLIYgxEZt8NIu3gpab0REyw37D0CNXqXui+sD1x0SZzNPlaxroux xQ1nZQnPYfAH7d4cLBm/tGyc1aMlfFw1BiUGynXB8v3tt21B1nTWNMWgfqc/O8EQD+4/ lG8muuc4PR/24/Sev/tHIOxJeCntVMUCClgk1EH1jEeE1xfmYLDFeQrMRWuVKf0Ow/Ho xrdw== 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=mWTWucCj62ZSQyWeoqHF8QcqQdqXam/8vtN0uJUf2WI=; b=gT0itPKKxzHA7a1oR4Ptc53BxpENEqm7ZqhYU2Zpda9qxEZLxvqqWmerQYzAEq3L5H C0rEy72PgjhgzJEZZLo7r2HHIbl5AQC4kGeL1W8xFUbrSYY7RUa/a9l8DzbdoYNvhT8p yIkt6qRrB8jFgGuiU5/ME7kL1jA9Yr6TK6JYdPCvT81DTbkbBtbxr8BhnAqiuD2pYH99 28KdIynGRtIZM+vu3NZHZWtG2+CjjFQzgJT24dkEeP8aeB7XuKGNbg5/d1cZU6O+iDmQ qhO//7J4jW/2wQ8nnSK/epuFNlDllzv9L2ZvyOuegCwTYZwF3uOr8jb0ABgaTBdKWf7u n8zg== X-Gm-Message-State: AIkVDXJ546dz8OxVECxgIFQl+ygEeh0fY6FAW068XyNj6qh5RSj3aZC9PA2hZQIWisyt7ssvlefTYT5h4iXiRw== X-Received: by 10.37.165.42 with SMTP id h39mr1480126ybi.132.1485426097992; Thu, 26 Jan 2017 02:21:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.80.215 with HTTP; Thu, 26 Jan 2017 02:21:37 -0800 (PST) In-Reply-To: References: Date: Thu, 26 Jan 2017 11:21:37 +0100 Message-ID: To: Niklas Keller Cc: Rasmus Schultz , PHP internals Content-Type: multipart/alternative; boundary=94eb2c1a03d6e939df0546fcb633 Subject: Re: [PHP-DEV] Not autoloading functions From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c1a03d6e939df0546fcb633 Content-Type: text/plain; charset=UTF-8 On Thu, Jan 26, 2017 at 10:46 AM, Niklas Keller wrote: > > > > Since the autoloading functions proposal is stalled, how about allowing > for > > import of static functions instead? > > > > use function Foo::bar; > > > > bar(); // calls Foo::bar() > > > > There are two benefits to this approach: > > > > 1. There is immediate support for autoloading without any need for > adoption > > or support in existing autoloaders. > > > > It adds "support". Just use a static method then instead of inventing some > new alias system. > > > > 2. Pseudo-namespaces (abstract classes with stateless static functions) > are > > already widely practiced in PHP - a lot of existing code would be > supported > > as is. > > > > That same code is already supported, no need for a language change here. > > > > The syntax when calling functions would be the same. > > > > If we had function autoloading, we would likely collect related functions > > in a file anyway - putting them in a class instead gives more less the > same > > exact result. > > > > The only drawback I can see, is the inability to import a whole set of > > functions with one statement - but being explicit about external imports > is > > widely considered best practice for classes and interfaces, so why not > for > > functions. > > > Just import the class and you're fine, you have just imported a group of > functions. > > > > Yeah, it's a bit inconvenient, but at least we can move ahead > > and leverage existing code without changes or BC breaks. It's not all > bad. > > It's better than nothing perhaps? :-) > > > > Thoughts? > > > > I don't see any benefits here, just drawbacks. It adds yet another alias > system, function calls can now be function calls and static methods. What's > with the static scope? It gets lost here. Nothing shows there's a static > scope. > A question in conjunction with this: How would this call actually treat the LSB and $this scope? Would it follow the normal rules for scoped method calls, or prevent adoption of scopes? For example: use A::__construct as ctor; class A { public function __construct() {} } class B extends A { public function __construct() { ctor(); } } Would this become an alternative way of writing parent::__construct() in B? Would it behave the same? Nikita --94eb2c1a03d6e939df0546fcb633--