Re: wacky object idea
| From: | Francis Smit | Date: | Tue, 29 Aug 2000 23:09:36 +0000 |
| Subject: | Re: wacky object idea | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-31134@lists.php.net to get a copy of this message | ||
"Stig S. Bakken" wrote:
> Francis Smit wrote:
> >
> > thies@digicol.de wrote:
> >
> > > On Tue, Aug 29, 2000 at 12:18:44AM +0200, Stig S. Bakken wrote:
> > > > Andrei Zmievski wrote:
> > > > >
> > > > > On Mon, 28 Aug 2000, Andi Gutmans wrote:
> > > > > > Operator overloading is one of the uglier features in C++.
> >
> > I would say that was one of the best C++ features
> >
> > > Java did things
> > > > > > better.
> >
> > Hardly Java is Brain dead, and all it's ecuses for not putting those features in
> > are complete nonsense.
> >
> > > Code is much more readable and maintainable when it uses interfaces
> > > > > > and not "object overloading".
> >
> > The revese is true.
>
> I don't intend to start a C++ bashing contenst, but I've dealt with some
> programming languages that do a lot of overloading, and some that
> don't. I have found "the WTF factor" as Rasmus calls it to be much
What is the WTF factor??
>
> higher in languages and projects using lots of overloading. Sure, it's
> cool to use operators for everything, it may make the code easier to
> read, but it also makes it harder to understand because it makes the
> semantics more obscure.
only if misused and who picks up libraries that abuse the language?
>
>
> Example:
>
> elems = str / ":";
>
> Easy to read, cool to write, but what does it do? It's doing this:
>
> elems = str.split(":");
yes but this is an abuse I have never seen this sort of thing in C++
if one codes like that most people will choose not to know you, I
sure would since there is no clear relationship between division
and string splitting.
>
>
> This form doesn't leave you with any doubt. Conclusion: if you want
> your code to be understood by others, avoid overloaded operators.
Negative if one only uses sane overloads, (or as in the case of inserters
"<<" ones which are well know alternate meanings), then no clarity is
lost. The development of new alternate meanings is of course a little
ticklish but, there are some sane rules that can be derived the above
example is fairly unlikely to take of as it involves not only the overloading
of the operator / as an operator but the conceptual over loading of a well
known mathematical operator, the operator << how ever is much simpler,
"<<" is not exactly an every day symbol as it is, so that the conceptual
overloading of it as both a shift and a insert operator, is much easier to
swallow, in mathematics (my first love) almost any symbol can be
conceptually overloaded, if PHP is going to be a sissy on these issues
then I can only say it's a pity, PHP shows much promise but I can always
look for something with a more practical and realistic out look, or create
it myself, that's the beauty of living in a free open source universe.
Respectfully
--
Francis Smit
Knowledge By Design/OzTel
Suite 201, 683 George st
Sydney 2000 NSW
http://www.kbd.com.au
mailto:francis@kbd.com.au
Tel: +61 2 9212 1399
Fax: +61 2 9212 5727
___________________________________
m$: How can we stuff you up today?