|
Boost Users : |
Subject: Re: [Boost-users] [Proto] implementing an computer algebra systemwith proto
From: Eric Niebler (eric_at_[hidden])
Date: 2009-01-28 10:45:57
Dave Jenkins wrote:
> It seems that any placeholder will match, not just the one you specify
> in the grammar.
>
> Below is an example program showing what I mean.
> I would expect that only placeholder1 would match,
> but both placeholder1 and placeholder2 match and produce the same output.
> I even tried using proto::exact to get the program to reject
> placeholder2, but that made no difference.
<snip>
Hi Dave,
You're passing an expression to a grammar to be evaluated with its
transforms. That expression must match the grammar. It's undefined
behavior if it doesn't, and in this case, it doesn't. "Performing the
transform" falls withing UB.
It would be possible to add a compile-time check to all grammars
function call operators to catch this error, but that comes with a
compile-time cost.
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net