Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33939 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19145 invoked by uid 1010); 11 Dec 2007 22:57:19 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 19130 invoked from network); 11 Dec 2007 22:57:19 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2007 22:57:19 -0000 Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:45231] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/B0-11541-EC51F574 for ; Tue, 11 Dec 2007 17:57:18 -0500 Received: from dslb-084-056-059-202.pools.arcor-ip.net ([84.56.59.202] helo=localhost); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1J2E2M-0003gh-IT; Tue, 11 Dec 2007 23:57:14 +0100 Cc: internals@lists.php.net Message-ID: <7ADAF424-D5CC-48F7-AF4C-4D8BC219C1CA@bitxtender.com> To: Stanislav Malyshev In-Reply-To: <475F10DA.6000909@zend.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Date: Tue, 11 Dec 2007 23:57:13 +0100 References: <11970653983080000@9866357972520000.9866341568840000> <475BDDF1.7040605@ctindustries.net> <1723341090.20071210220025@marcus-boerger.de> <1197323296.3922.5.camel@sbarrow-desktop> <00A2E2156BEE8446A81C8881AE117F199A0715@companyweb> <475ED038.3080004@zend.com> <7F9E1E02-FF89-474B-9E94-007747B3637A@bitxtender.com> <475EF175.2030304@zend.com> <475F01B1.8090407@zend.com> <31696FA6-ADC3-4853-A5AE-23FA16750B3D@bitxtender.com> <475F10DA.6000909@zend.com> X-Mailer: Apple Mail (2.915) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1197413839;29455652; Subject: Re: AW: [PHP-DEV] Namespace resolution From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) Am 11.12.2007 um 23:36 schrieb Stanislav Malyshev: >> import Name::Space; >> // only stuff from Name::Space available, no PHP internal stuff >> import __php__; >> // now PHP's classes are loaded, too. > > So "import php" make internal classes always take priority even when > there's a class in this namespace by that name? But you could > achiever the same just by avoiding naming classes the same as > internal classes, you surely know which classes are in your own > namespace? Since in both cases code change is needed, why that one > is better? If you created Name::Space::DateTime, surely there was > some intent in having it named specifically the same as DateTime > class in PHP? Ah. Now that you mention it, there was a flaw in my logic. The idea was not that PHP classes take precedence, but in this case, PHP's DateTime class would already be "loaded" so no autoload would be attempted for a Name::Space::DateTime. If, however, that Name::Space::DateTime was already autoloaded by the time we reach that code, things would just break. Hmmh. Jochem pointed it out in the other message; I think this autoloading thing is going to be tricky... > Java package system is very different. For starters, they don't have > global space at all. And they have offline compilation stage which > verifies all the dependencies. Yes, sure. I was just saying that other languages also require you to import language-internal stuff from time to time. >> I don't think that PHP's internal stuff needs to be magically >> available. We can force developers to explicitly request access to >> it. > > We can, but we should not. Internal classes are internal for a > reason - people use them a lot. Making it hard to access frequently > used classes to enable rarely used functionality is not the right > way to go. Okay, but what do we do about the issue described initially then? Here's a concrete example to show the problem: namespace Name::Space; class DateTime {} namespace Name::Space; class Ship { public static function __autoload($className) { // ... autoloader, can load Name::Space::DateTime } } function someStuffWeDoNotHaveControlOver() { $foo = new Name::Space::DateTime(); // ... } require_once('Name/Space/Ship.php'); spl_autoload_register(array('Name::Space::Ship', '__autoload')); require_once('setup.php'); import Name::Space; $d = new DateTime(); // a PHP DateTime someStuffWeDoNotHaveControlOver(); $d = new DateTime(); // a Name::Space::DateTime now! See what I mean? David