From: joel de guzman (isis-tech_at_[hidden])
Date: 2001-06-02 10:47:11
From: "Ed Brey":
> From: "joel de guzman" <isis-tech_at_[hidden]>
> > I tried for example to find logic behind my dislike for +
> > for concatenation. Addition is *not* concatenation, I
> > asserted. Addition implies a + b = b + a. Commutative.
> > I opted for a non-commutative operator. That was one
> > of the reason for Spirit's use of >>, after all I believe
> > arrows clearly denote sequencing.
> Commutatively is a property of the semantics of an operation. Since
> is not related to math and doesn't have a concept of addition, there is no
> reason to expect + to follow addition's commutative semantic. Contrarily,
> std::string has the concept of concatenation, which is represented by a
> non-commutative +. Since a grammar uses the same concept of concatenation
> as std::string, it is logical to use the same operator.
> A grammar also has a relation to an istream, in that variables in the
> expression are assigned values based on an input. However, using
> >> operator might cause confusion, since the usage would be similar, but
> still a bit different between the two domains. Also, from an aesthetic
> point of view, >> seems to really bulk up the screen, whereas + is small
> clean, which is nice for the commonly used operators.
As I said, this is very subjective. What is considered aesthetically
pleasing to some is ugly to others. We could go on and on arguing
about this. I could assert that the string's use of the + is ugly (it is!).
I could say that the shift operators is already somewhat abused by
the iostreams (it is!). The = is abused (overloaded) by the programming
world. And so on and so forth. ad infinitum.
Joel de Guzman
PS. For what it's worth, I've mellowed down in my dislike of
the + for sequencing. One reason is that I stated that it clashes
with the positive closure (+) [ and I will die for the + closure ;-) ]
I realized that, based on Greg Colvin's argument:
+a ---> a | a + a | a + a + a ....
And as you said, there's a prior use on strings We'll see :-)
PS> Hey Greg, let's push for the white space operator!!!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk