quote:Original post by Raghar
It''s strange because it''s just a syntax sugar.
Everything except for CPU microcode is syntax sugar(sic).
quote:Original post by Raghar
It''s strange because it''s just a syntax sugar.
quote:Original post by Raghar
What is this.
A*B
Is it addition, or sorting?
quote:Original post by Arild Finesquote:Original post by Raghar
It''s strange because it''s just a syntax sugar.
Everything except for CPU microcode is syntax sugar(sic).
quote:Original post by GnuVincequote:Original post by hpolloniquote:Original post by Oluseyi
I concur. The rationale was that operator overloading is often abused, and the Java mantra is to eliminate anything that is potentially confusing, obscure or "dangerous". It''s a pretty tame language. Nevertheless, the C++ operator overloading syntax is fugly, unintuitive and necessitates the addition of another keyword (operator). The elegant way to do it would be to have certain specially-named functions (perhaps with leading underscores, indicating their reserved status) which, when implemented, were evaluated as symbolic operators.
Oluseyi is now officially a D fan
Exactly like Python too:class MyClass: def __add__(self, rhs): # Do stuff def __getitem__(self, index): # Do stuff def __setitem__(self, index, value): # Do stuff
But I''m not fan of this. What is __setitem__? I like how Ruby does it:class MyClass def +(rhs) # Stuff end def [](index) # Stuff end def []=(index, item) # Stuff endend