Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94552 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69000 invoked from network); 18 Jul 2016 13:58:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2016 13:58:01 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.44 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.44 mail-wm0-f44.google.com Received: from [74.125.82.44] ([74.125.82.44:37151] helo=mail-wm0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/F1-52781-860EC875 for ; Mon, 18 Jul 2016 09:58:01 -0400 Received: by mail-wm0-f44.google.com with SMTP id i5so118120788wmg.0 for ; Mon, 18 Jul 2016 06:58:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=eGj8bNIUvzgoueLUuMqEIOqvcpghcxL6w+peWc3eOng=; b=vq1I5EIl3B+SNy6zDK+L7FPoOPAFWzPZpCc0RemETE6eUXhiVvk8bdBjB45hftNRrg L1T6f5q8jb8pGV7fLFh0HywYVWBd+1lA2JpsNf2DXVD9Qt5PnYt9p5kjz4kPqW5nUoAy z970fmaSXZpGNoB45KSomkOibopq/jOpUpDe6JXZ2kne4mK2Zj3JC+v1ZS6godgKfBPZ pFaXg93HF4mMuPM6FXiHN2XOXpKmQUqqG87J7fwGFiY6nn2tvh+zxIW81UcLmIIBvx95 x3l084F70pIu+W+uxJJGmiZk4UY9bIFIx6qZRqKFn09kmG8lMFyA9mVIG9srez6i03qy pTcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=eGj8bNIUvzgoueLUuMqEIOqvcpghcxL6w+peWc3eOng=; b=Z6yb6RRUhuINyIn82XMGUlj7rl4bxeNUK32kzklIWvIfTvlyJsJnyEnX9Y4tzDxWmj ytyKobFNoZx08gfC7t/MkIKJVCQMSa3xtrb2TiCGwnEoMc5KI8GZ/mM50ReV2RzhmZ+f eB9tCTfHYCvzV2jSyi5sSr4x8n6ExpCHr1ZR0MFPai6JU01hT5mfWhLKmfjeymNB5mH/ Q9burT6qHa5pATtJdTWr4As2mVB/Sy/ERoy8u1/3mIs7VeMTdu+KjrHxKkrIvqDFl/kr yQy3dBvyTxw2P41S6l2cRq9VKyiaYyCv3piWWNdh4/JxN1/QpquG4YlRdCDBXj4t98SB wUFg== X-Gm-Message-State: ALyK8tK4wQ199dfUXXPbRyREF+sirifsI7GoCGVRoR05joIPvYed6u5G+jmmEEmv2I2+2A== X-Received: by 10.28.87.3 with SMTP id l3mr56409280wmb.71.1468850277497; Mon, 18 Jul 2016 06:57:57 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id qf3sm1440662wjc.17.2016.07.18.06.57.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jul 2016 06:57:56 -0700 (PDT) To: PHP Internals References: <3567286a-e942-1551-c300-663a50b0f484@gmail.com> Message-ID: Date: Mon, 18 Jul 2016 14:55:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <3567286a-e942-1551-c300-663a50b0f484@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Idea: Function autoloading using dummy namespaces From: rowan.collins@gmail.com (Rowan Collins) On 18/07/2016 01:50, Stanislav Malyshev wrote: > Hi! > >> How about an alternative approach where a function inside a namespace >> can be autoloaded using the existing callback, by using a reserved >> namespace segment? So to autoload function "foo\bar()", the engine would >> construct a string like "__function\foo\bar" or "foo\__function\bar", >> and pass that to the registered autoloader stack. > > Magic out-of-domain values usually are bad design, and lead to a lot of > trouble since now the system needs to deal with two sets of assumptions > instead of one. I wouldn't recommend doing it. > Hi Stas, My original idea was actually to have the autoloader look up "foo\bar\__functions" for *any* function in namespace "foo\bar", with the idea that some existing autoloaders would actually be able to work without any modification (just call your file "__functions.php"). If you include the function name (to give users more flexibility), that doesn't really work (unless you have one function per file), so you're right that it requires some muddling assumptions. I agree that it's all a bit magic either way, but I thought it might get the feature moving quicker than a complete rewrite of the existing autoload system. Like I say, it was just an idea. :) Regards, -- Rowan Collins [IMSoP]