[M3devel] Enumeration or subrange value out of range

Hendrik Boom hendrik at topoi.pooq.com
Thu Dec 2 15:12:56 CET 2010


On Thu, Dec 02, 2010 at 02:36:05PM +0800, Michael Richter wrote:
> On 1 December 2010 14:49, Jay K <jay.krell at cornell.edu> wrote:
> 
> No, it is not.  The semantics of concatenation are hugely different from the
> semantics of addition.  Consider 3+4 vs. 4+3.
> Now consider "three"+"four"
> vs. "four"+"three".  If you want to do concatenation, have an operator for
> concatenation.  (++, say, as a random example.)  Do not overload addition
> with an operation that isn't even vaguely analogous.

The semantics of matrix multiplication are hugely different from those 
of integer multiplication.  Consider A*B vs B*A.

By this this doesn't mean that we necessarily need a different operator 
symbol.

For string concatenation, there's even a homomorphism (length) mapping 
it to natural number addition.  Just like determinant for matrices.

> 
> 
> >  > utterly painful uses for operator,)
> >
> 
> 
> > I'm surprised that is overloadable, but indeed it appears it is. I don't
> > think I have *ever* seen anyone overload it, and I have seen a lot.
> >
> 
> I would tell you how I used it, but I'm utterly ashamed of that portion of
> my life.  ;)  (It was in a type-safe SQL query builder.)

That sounds as if you were defining . to be a reasonable approximation 
to SQL's . That sounds like a reasonable thing to do -- except if any of 
its uses would have to be disambiguated with C++'s hopelessly 
complicated disambiguation rules.
 
> 
> Operator overloading can multiply these by orders of magnitude and have the
> added problem of being, in effect, "COME FROM" statements.

Those were fun.  Good thing no one took hem seriously.

> My C++ days are a decade behind me so I no longer have any source that
> illustrates this.  I just recall that any time we had a templated class with
> overloaded operators that it turned into an asinine stew of unreadable code.
> 
> 
> > The one vague reason I don't fully understand is: C doesn't have it.
> > Does C represent a good example of a sort of minimalism? Maybe.
> > It isn't clear to me the value of C. It has been *very* widely abandoned in
> > favor of C++.

I use the subset of C++ that's more or less equivalent to C.  It gives 
me slightly better type-checking, but that's the main benefit.

Very rarely I use single inheritance.  If I do anything that involves a 
lot of that, I prefer Modula 3.

> 
> What is the FFI lingua franca again?  C or C++?  (Hint: one of those two
> languages has syntax to make it compatible with the other, but not vice
> versa.)

C has interfacing specs that are more or less consistent from machine to 
machine.

C++ doesn't seem to.

> 
> -- 
> "Perhaps people don't believe this, but throughout all of the discussions of
> entering China our focus has really been what's best for the Chinese people.
> It's not been about our revenue or profit or whatnot."
> --Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.

More demonstrating how difficult some ethical decisions, even with the 
best of intentions.

- hendrik




More information about the M3devel mailing list