From: Charles D Hixson Date: 2006-11-23T02:37:12+09:00 Subject: Re: Ruby vs Java vs c++ M. Edward (Ed) Borasky wrote: > Charles D Hixson wrote: >> Operator redefinition can be seriously abused. It's also something >> that's very powerful when done correctly. I can see an argument for >> requiring that the *standard* operators not be redefined. This >> doesn't mean that there shouldn't be user defined operators that CAN >> be treated just as any other (virtual) function. Perhaps a >> requirement like "A user operator must begin with a '|' character and >> contain no whitespace in it's name. It may contain any other >> non-control character, and must be delimited by whitespace." would >> suffice. > Bah! Double Bah! Triple Bah! > > 1. Every programmer is entitled to define his or her very own personal > programming language using whatever syntax and semantics makes the job > easy. As long as it's simply a dialogue between one programmer and one > machine, who else cares? > > 2. *However*, the minute a second programmer, a manager, a user, or > another machine enters the picture, that programmer needs to > communicate with more entities, thus requiring a standardized language > *and* a meta-language for communicating about the language. > > 3. Programming languages evolved from symbolic logic, algebra and > English, at least here in the USA and in the United Kingdom, where the > initial development was begun during WW II and the early years of the > Cold War. (No, I haven't forgotten about Konrad Zuse or the early > Russian computers -- they just didn't have much influence on > programming languages). > > C++ has *way* too many features, both syntactic and semantic, to be of > much use to me. Sure, any programmer can work in a readable subset of > C++, but most don't. Most have their own team dialect of C++. As far > as I'm concerned, there's only one usable dialect of C++ -- ANSI C. :) > You are thinking about C++. I am thinking about Eiffel and Ada and Python. C++ got LOTS of things wrong, and only became popular because it was an effortless transition from C. You are taking a warning from C++. I am taking a warning from Algol98. There's lots of ways to design something improperly. Just because one of them is selected doesn't mean the basic idea is wrong. (C++ also gave multiple inheritance a bad name. Eiffel proved that the bad name wasn't justified.) Mind you, every language has it's warts. More important than allowing liberal operator redefinition I believe would be the optional inclusion of function name on the matching end statement. This would allow many errors to be localized. Think of it as a "compiler hint". NOTE: an operator *IS* a function. If you are against user defined operators, then for consistency you should be against user defined functions. I really doubt that you are going to pick that choice. P.S.: I think that the way Python defines operators works well for the "built in" operators, but I'm not sure that it's appropriate for generalized user defined operators. The form I used in Eiffel was to precede and follow the operator name with a pipe character, thus: |*| for matrix multiplication. Eiffel allows(allowed?) this form, but doesn't encourage it.