Boost logo

Boost :

From: joel de guzman (isis-tech_at_[hidden])
Date: 2001-05-30 13:48:37


From: "George A. Heintzelman" :
>
> > Example:
> >
> > a = b;
> > a = c;
> > a = d;
> >
> > Equivalent to:
> >
> > a = b | c | d;
> >
> > But there's a runtime penalty.
>
> I appreciate that you don't allow this syntax, but if you were to
> change your mind, I would find the equivalence you state above very
> counter-intuitive. I would expect the three assignments to be
> equivalent (if there were no intervening statements) to just a = d.

:-)

Please remember that it is BNF we are modeling here. It just
so happens that ::= in BNF is = in Spirit. I've seen some
grammars being defined this way. (E)BNF is declarative
in nature (not imperative). This is much like template
declarations where a class template is specialized:

template <typename T> class X {};
template <> class X<int> {};
template <> class X<float> {};

>
> I would expect that:
>
> a = b; a |= c; a |= d;
>
> to be equivalent to
>
> a = b | c | d;

Looking at it in the destructive assignment point of view, yes.

>
> If you ever allow rules to be redefined, please be careful about the
interface you decide to use for it. Very important would be the case:
>
> Rule a = <pattern 1>
> Rule b = <pattern 2>
> Rule c = a | b;
>
> b = <pattern 3>

Agreed. I'll always ask you guys first.

> Now, does using c give you <pattern 1> | < pattern2> or <pattern1> |
<pattern3> ? I think I would want it to be the former, but I can see
arguments both ways.

I see your point. The current version of Spirit disallows redefinition.

But if it was allowed, it would be c = <pattern 1> | <pattern 2> | <pattern
3>
since b = <pattern 2> | <pattern 3>

*Sequence does not matter*

>
> But since this isn't done right now, I guess it is mostly a moot point...
>
> George Heintzelman
> georgeh_at_[hidden]
>

Maybe.

Cheers,
Joel de Guzman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk