From: Ed Brey (brey_at_[hidden])
Date: 2001-06-02 10:15:59
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 grammar
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 istream's
>> 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 and
clean, which is nice for the commonly used operators.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk