Re: wacky object idea

From: Date: Mon, 28 Aug 2000 17:58:42 +0000
Subject: Re: wacky object idea
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.dev 
Request: Send a blank email to php-dev+get-30995@lists.php.net to get a copy of this message
Quoting Andi Gutmans <andi@zend.com>: > Do I think you should be using a different language? Well it depends what > you are looking for. If you are looking for operator overloading I think > you should use C++. Fair enough. I don't want operator overloading. I don't want to use C++. > If you are looking for a fully object oriented strongly > typed programming language you should use Java. If you are looking for a > scripting language you should use PHP. Also both fair enough. I want a scripting language which allows me to cleanly write re-usable components. This is not an OO issue, though some people seem to associate components, re-use, and objects for some reason. It's really a packaging/namespace issue. I've started using objects heavily in php because they give me a way I can wrap up a bunch of code, in a way that I'm pretty sure it won't conflict with other code, and drop it into another application. Php's current OO support _almost_ provides everything in this regard. It'd be great if we could have static class variables, so that you could use a class as just a package containing a bunch of functions and still have some class variables defined. Right now you can't even set defaults inside a class and use them in a static method. It'd also be great to be able to make constants part of a class's namespace instead of global. Both of those features would just let you keep a little bit more inside of the packaging that a class provides - less chance that you will conflict with something that a user of your package is already using externally. The final piece in terms of packaging would be a way to dynamically rename a class/package; ie: import DB as myDB. This would let you avoid namespace conflicts once and for all, since the application author would control what parts of the namespace the packages he used took up. However, unless it turns out to be easy and efficient to implement, I can live without it. Also, I don't particularly care if this features are tied to classes or not. If I could declare a namespace, and then have constants, classes, functions, and variables exist inside that namespace, that'd be great, and I wouldn't worry about static class vars or constants inside classes. > When dealing with a language there are a zillion of places you can get > bitten so we need to think well about how these kind of changes would > effect the language on a whole, the spirit of the language, and the > performance. When a user wants a feature he is not always aware of what > implications the feature could have. Yes, I completely agree. I've tried to keep my tone in the "is this possible?" range; I apologize if I've come across as pushy. > My opinion: I would probably want to see exceptions instead of this "wacky > object idea". That would be great. I kind of went off-track up above; this would solve my original feature request, which had to do with clean error handling, which is the other piece I'd like to see php have. And again, I don't particularly care if it's done in an object oriented way - although php's current object support should work well with it. -chuck -- Charles Hagenbuch, <chuck@horde.org> -- relevancy is the opiate of the masses

« previous php.dev (#30995) next »