On Saturday, February 26, 2011 11:28:58 PM alfC wrote:
> On Feb 25, 11:57 pm, Thomas Heller <thom.hel...@googlemail.com> wrote:
> > On Saturday, February 26, 2011 08:49:25 AM alfC wrote:
> > > On Jan 31, 5:43 pm, "Hartmut Kaiser" <hartmut.kai...@gmail.com> wrote:
> > > > Hi List,
> > > >
> > > > PhoenixV3 is nearing its completion.
> > > >
> > > > With the port to Boost.Proto we tried to address the outstanding
> > > > issues of the review and would like to announce that
> > > > themini-review will start on February 19th.
> > >
> > > Thank you for the new version of Phoenix-3. I wonder if things like
> > > phoenix-expression matching is now possible as "promised" in this
> > >
> > > thread:
> > >http://lists.boost.org/boost-users/2010/05/59491.php
> >
> > Yes, stuff like this could be indeed made possible.
> > Though, I don't see where phoenix comes into the game in the examples
> > in this thread.
>
> I was doing things like this with Phoenix2 by hacking the internals:
>
> in a function call like this
>
> integral( 'arbitrary phoenix expression' , interval(2., 4.));
>
> I was matching, first that the passed expresion is of the form #1/
> ( phoenix::_1 - #2), if so it checked that #2 is a 'double-type'
> value, then extracted that value and then passed the whole thing to a
> numerical intergrator that handle functions with sigularities at the
> value of #2. If the expression didn't match then a generic integrator
> is called.
Nothing easier than that, no need to hack (more or less) undocumented internals of the library. Every phoenix expression can be matched with proto's grammar matching facilities:
struct singularity :
proto::when<
proto::divides<
proto::_
, proto::minus<
phoenix::expression::argument<1>
, proto::_
>
>
, proto::_value(proto::_right(proto::_right))
>
{};
Match arbitratry expressions with proto::matches ... call the transform to get the singularity, etc.
> Thanks,
> Alfredo