Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20068 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47319 invoked by uid 1010); 16 Nov 2005 16:25:51 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 47304 invoked from network); 16 Nov 2005 16:25:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2005 16:25:51 -0000 X-Host-Fingerprint: 194.109.193.120 unknown Linux 2.4/2.6 Received: from ([194.109.193.120:34767] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 1F/CF-07637-F8D5B734 for ; Wed, 16 Nov 2005 11:25:51 -0500 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id DE7B3186E9E; Wed, 16 Nov 2005 17:25:52 +0100 (CET) Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (moulin [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32629-20; Wed, 16 Nov 2005 17:25:51 +0100 (CET) Received: from [192.168.1.16] (bspr.xs4all.nl [194.109.161.228]) by mx1.moulin.nl (Postfix) with ESMTP id E0387CB6CE; Wed, 16 Nov 2005 17:25:50 +0100 (CET) Message-ID: <437B5D88.9050201@iamjochem.com> Date: Wed, 16 Nov 2005 17:25:44 +0100 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Matthias Pigulla Cc: internals@lists.php.net References: <00A2E2156BEE8446A81C8881AE117F192C1B31@companyweb> In-Reply-To: <00A2E2156BEE8446A81C8881AE117F192C1B31@companyweb> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at moulin.nl Subject: Re: AW: [PHP-DEV] interface method visibility. From: jochem@iamjochem.com (Jochem Maas) Matthias Pigulla wrote: >>why does the engine care about the visibility of interface >>methods I declare? >>I understand the argument that interface methods only have >>'meaning' when applied as public methods of objects - but >>thats rather academic and personally I can think of useful >>ways to abuse interfaces using protected methods at the very >>least why am I not allowed to do this just because someone >>decided that its not correct? > > > Having anything else than "public" in an interface simply does not make > any sense - an interface serves as a contract to external clients. It > guarantees them that there will be a set of methods they can call on an > object instance. What should be the semantic meaning of non-public > elements in interfaces? thats not my problem though is it - and I did mention that I already understand what you you are now repeating. I had a good reason to create an interface whose methods were only relevant to the innards of a particular (rather large for my doing) class hierarchy - I don't give a rats ass as to what you think the 'semantic meaning' of that should be - it worked in the 5.0RC1, I understood what I was doing and I was happy doing it. I certainly was not forcing you to do it too, so why force me to rewrite/hack my code (sometimes you devs have to do this because I abuse things like array_pop() ;-) but I don't feel that this is the case here at all). > > >>and given that I can implement a non-static method without >>using $this or any other symbol/code related to the >>instantiated object (effectively creating a static method) >>which I can call using static notation why not allow static >>interface methods? > > > As to static interface methods - same as above. An interface is an > interface :), not an implementation. So you will never have methods > implemented in an interface. The interface just says "the class > implementing the interface has a method named xy() that you can call". > > So how would you make the static call on the interface? > ISomewhat::someMethod()? Where should that be implemented? This is why > you always need an instance that implements the interface and you make a > "normal" call on this instance. PHP allows - as opposed to C# or Java > (IIRC) - to call static methods on instances. right which meant in one particular case I had to create an object especially to call the given method, very wasteful, pointless and the only good reason there seems to be is some academic crud which you have reiterated here. > > I think the fact that you can call nonstatic methods statically is BC > with "early days"; you don't want to do that in your code because it > will get you problems sooner or later. In "older" code you could not > mark methods as static, so the language could not check if a static call > is allowed. It simply permitted the call, not setting $this. everything I mention here is related only to my experience with php5 and up since Nov'03. > > >>also I noticed that using the keyword 'abstract' with a >>interface method declaration is all of a sudden (5.1RC5dev) >>causing a fatal error where before (5.0.2 - 5.0.4) no error >>what so ever. > > > I thought I would never write anything like that - but: What sense does > "abstract" make in an interface at all? the point is it doesn't hurt _you_ to let _me_ do it. if it makes sense to me but nobody else thats no reason not to allow it on grounds of principle when it is clear that it has worked without problem. > > You shouldn't have been writing "abstract" in an interface in the first > place. >:) thank you very much - how enlightening. the engine can safely ignore the 'abstract' regardless at that point. no E_FATAL required. besides semantically an interface is abstract as are the method declarations in it, I am not allowed mark a method in an interface as 'abstract' but I'm not allowed to give it a body either - notice a slight discrepancy? or are you saying that the 'abstract' keyword in the declaration of an interface method opens the doors for painful/impossible to debug segfaults? if so I'll retract my opinion. > > >>If 'static', 'protected', 'private' are not allowed with >>interfaces (very unpragmatic imho) then why the fatal errors? >>why not an E_STRICT and just ignore those declaration... > > > As I understand it, E_STRICT is for complaining about stuff like "var" > that was ok with PHP4 but is discouraged in PHP5. But you are using PHP5 > elements in a way that make no sense to the language, so it's simply an > error. and as I understand it E_STRICT is for pedantic checking - i.e. check if every t is crossed and every i dotted (so to speak) nothing perse to do with php4 (or will E_STRICT be dropped when support for php4 code is dropped from the engine?) anyway that was merely a suggestion - basically the E_FATAL is bogus imho. > > >>especially because not declaring a method static and leaving >>off the visibility leaves you with a method that is >>non-static and public - exactly what an interface 'requires'. > > > You're explicitly requesting something that is not possible - an fatal > error is the only thing that can be the result. if its not possible then I what flippin' universe have I been coding in for the past 2 years??? the only thing making it 'not possible' is self-imposed purism. > > Matthias >