4 ms·
I'm wondering what the author would make of Perl 6, which both embraces Unicode and allows the programmer to create new operators from arbitrary collections of
by colomon 16y ago
I'm wondering what the author would make of Perl 6, which both embraces Unicode and allows the programmer to create new operators from arbitrary collections of Unicode symbols. It seems like his fondest dream and his worst nightmare at the exact same time -- which makes me think he may be less than perfectly clear on what he wants.
I've never understood the arguments against operator overloading. Yeah, you can create unreadable programs that way. But it's equally easy to create a function named "sort" that erases your hard drive. If you apply the same disciple to naming your operators that you do to naming your functions, it's not hard to understand. And it's a huge boon if you happen to be (for instance) defining a new numeric type.
- Hubbert 16y agoI once defined a class of 3-D vectors and overloaded operators to them, but I agree with the problem. The problem is that redefining core symbols creates a larger communication problem than defining new symbols: if I see sort(), then I'll go look up the definition of the function. But if I see (-a + b || c) in some languages, I have to check that you didn't overload - to your sort() function and || to transpose. Redefining language is one characteristic of cults (http://www.orange-papers.org/orange-cult_a0.html#ca_cult_speak http://www.orange-papers.org/orange-cult_a0.html#ca_cult_spe...). I say this not to cast aspersions, just to communicate the damage that can be done when symbols are redefined. Better to invent a new symbol for a new idea. (for a non-programming example of redefining
- rwmj 16y agoI don't know what people have against overloading either. Nevertheless, "delimited overloading" is like overloading, but safer, since the overloading is limited to some scope, and readers can easily see where overloading is allowed. In OCaml you can now write something like: Big_int.( 23 567 mod 45 + "123456789123456789123456789") where only the operators in the parentheses are overloaded. http://pa-do.forge.ocamlcore.org/ http://pa-do.forge.ocamlcore.org/