# Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-05-25 23:03:51

From: joel de guzman <joel_at_[hidden]>
> Hi,
>
> I am having second thoughts with the + operator for
> sequencing. At first, it seems to be ok but further
> use of the operator gives me a feeling that something
> is wrong.
>
> Why I dislike the + for EBNF sequencing:
>
> 1) The same reason why I dislike string's + operator for
> concatenation. Concatenation and sequencing is *not*
> commutative. a + b should be equivalent to b + a. I
> feel that this is wrong and should not be propagated.
>
> Among all the other binary operators in Spirit, only this one
> violates the basic laws of commutativity as basically understood
> of the operator. I believe an accepted non-commutative operator
> is more appropriate.
>
> 2) EBNF operators [|&-^] are 'set-like' operators. It is
> quite common to see | to mean set union, & to mean set
> intersection, - to mean set difference and ^ to mean set
> exclusive or.
>
> Yet it is also common to see the + operator as a substitute
> for set union. Although this is arguable in the view point
> of the rule: "when in doubt, do as the ints do", since
> a | b != a + b (for integers), some set libraries and even
> languages do use the + as a synonym for |. For some this
> closely resemble the mathematical set operator (+ enclosed
> in a circle).
>
> 3) It clashes with the meaning of + in EBNF and regular
> expressions which is solely used for iteration and means
> repeat one or more. One of the goals of Spirit is to
> mimic as closely as possible the syntax of EBNF.

None of the above bother me, but you are the designer. EBNF
is far enough away from algebra that I don't expect perfect
analogies, and infix + has long been used for concatenation.

What we really need is this:

;->

> Possible substitutes:
>
> a >> b >> c... The original Spirit syntax. >> arrows denote sequencing.
> Non-commutative

Ugly.

> a / b / c ... Non-commutative. Similar to unix file paths and URLs e.g.
> root/development/c++/myfile.cpp

Livable.

> a % b % c... Non-commutative. A bit of an eye-sore though

Less of an eyesore than <<.

And don't forget

a*b*c

Commutative for numbers, but not matrices, and a common
substitute in computer languages for

a b c

in algebra. Nice high precedence too.