Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:8091 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25964 invoked by uid 1010); 23 Feb 2004 21:42:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 25889 invoked from network); 23 Feb 2004 21:42:19 -0000 Received: from unknown (HELO usstp06.itcs.purdue.edu) (128.210.5.245) by pb1.pair.com with SMTP; 23 Feb 2004 21:42:19 -0000 Received: from localhost (wm-tn1.itcs.purdue.edu [128.210.11.239]) by usstp06.itcs.purdue.edu (8.12.10/8.12.10/scan-smtp) with ESMTP id i1NLgIfr004740; Mon, 23 Feb 2004 16:42:18 -0500 Received: from 12-222-106-63.client.insightBB.com (12-222-106-63.client.insightBB.com [12.222.106.63]) by webmail.purdue.edu (IMP) with HTTP for ; Mon, 23 Feb 2004 16:42:18 -0500 Message-ID: <1077572538.403a73ba0a685@webmail.purdue.edu> Date: Mon, 23 Feb 2004 16:42:18 -0500 To: Marcus Boerger Cc: PHP Development References: <1077090830.30573.1.camel@coogle.localdomain> <200402212010.53919.zhundiak@comcast.net> <1077427838.40383e7e58b76@webmail.purdue.edu> <691103866843.20040223191600@marcus-boerger.de> In-Reply-To: <691103866843.20040223191600@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2-cvs X-Virus-Scanned: by amavisd-new Subject: Re: [PHP-DEV] Re: Static weirdness.. From: fuhs@purdue.edu (Josh Fuhs) Quoting Marcus Boerger : > In fact it may be related. As i said before it is one of the ways to get to > a class. > The class is related to the object. The method is related to the class. Is the method related to the object? It is not. There are many indirect ways to get to a class. I'll try to illustrate with an example. Say that we introduce a new semantic rule that says you can call methods on arrays. The behavior is to scan through the array for any object on which it can call that method. i.e. $array = array($object1, $object2, ...); $array->method(); /* Calls method on all objects in array. */ Could that be useful to coders? Yes. Is it a good language element? I would argue no because the array is not directly related to the method. Quoting Hartmut Holzgraefe : > So why? as i stated before the only difference between static and > non-static member functions is that non-static members *may* change > the state of an instance while static members definetly won't > > From a callers point of view it is not even important to know > that one is calling a static member when invoking the member > function over an object instance, so why shouldn't it be callable > like that? > With non-static methods, you KNOW that the object is required in order for the method call to be valid. Thus the statement $object->nonStaticMethod() includes all of the information required for execution and no more. I agree that it's logically safe to continue with the current semantics, but it introduces a few maintenance headaches. When reading through code, it helps to be able to know exactly what is being affected without having to refer to any documentation or code. I agree that reading documentation is important, but if it's not necessary, then it shouldn't need to be done. Consider the case where an object needs to be altered/removed from a solution for one reason or another. Each place where a static method call is made from that object has to be examined (i.e. refer to documentation). Depending on the project, the number of these could be very large, whereas simply indicating the class directly would alleviate that extra work. It adds virtually no extra work for the original coder, since they are probably familiar with the objects they are manipulating. This is similar to the excessive use of global variables. I've had to maintain software where the original author thought it best to use global variables as function parameters. Doing so relates the parameter to the whole of the global scope. This makes code maintenance a huge pain. Had the minimal relation been used, this coder simply would have added a few more parameters to that function's parameter list. Granted, that's much more of a pain than the static methods, but the idea is similar. So I guess my message is minimalism. I am completely in favor of a $className::... syntax. It is consistent with the $object->$elementName and $functionName() syntaxes which I consider to be very strong points for PHP. Also, if the $object->staticMethod() scheme is to persist, for the sake of consistency, it would be nice to see $object->staticMember and $object->CONSTANT This is kind of part of my argument against $object->staticMethod() because I imagine those would also create some headaches. Josh