Boost logo

Boost :

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


From: "Larry Evans":

> joel de guzman wrote:
>
> > It's not just the performance. It is also the flexibility. The Spirit
> > framework uses compile time polymorphism as much as possible.
> > My experience is that pointers (needed for runtime polymorphism)
> > are *not* needed anymore. The type says it all. And arbitrary types
> > can be composes and structured, using template techniques, to
> > form more complex types.
> >
> > Thus there is no *encapsulating* class in the Spirit framework,
> > such as the BNF class in your proposal, that is needed to manage
> > the lifetime of the rules. Rules are stand-alone in the Spirit framework
> > and are dealt with by value, instead of by pointer or reference, which
> > would otherwise require garbage collection or reference counting,
> > which is another potential performance problem to take into scrutiny.
> >
>
> You could probably do it some other way, but I think use of pointers would
> be more programmer friendly. I think one problem with using just values
is
> that each instance of, say variable X (variable means non-terminal),
> is distinct throughout all occurrences in the grammar. However, to
create an
> LL(1) parser, each variable needs to be annotated with FIRST and FOLLOW
> and NILLABLE attributes. So if each X is distinct, in which X will these
attributes be
> stored? Or maybe in some map<X,LL1attributes> ?

Aggregates need not store subjects by value. A reference is fine since we
know that the subject has a lifetime equal to or greater than the aggregate.
Rules<> are composed by reference in Spirit. I such cases, the aggregate
does not own the subject(s).

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