|
Boost Users : |
Subject: Re: [Boost-users] proto: analytical-only math functions
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-03-14 15:52:31
-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Eric Niebler
Sent: 14 March 2009 17:37
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] proto: analytical-only math functions
Hicham Mouline wrote:
> Eric Niebler wrote:
>> And if I'm right in assuming that the first parameter of
>> derivative is which derivative to take, you'll need to make that
>> information available at compile-time as well, so:
>> let( f(x) = log(x) )[ g(x) = derivative<1>(f, x) ];
>
> I am thinking about user friendliness.
> I think I will have the user define this:
>
> typedef proto::terminal< function_tag< mpl::size_t<3> > >::type
> function3;
> function3 f( x1, x2, x3, x1+ x2+ x3+ c6 ); // after all, store the
> expression tree at runtime
>
> 1. Can I define a constructor for the terminal like this?
>You could, but ...
> 2. Can I store the expression tree somewhere? Inside the function_tag
> template?
>You could store the expression tree within such a function3 object, but
>only by erasing its type. (See
>http://www.artima.com/cppsource/type_erasure.html for more on type
erasure.)
>Look at the type "function3" you've defined above. It has absolutely no
>compile-time information whatsoever about what expression might be
>stored inside it. If you want to use this variable in more complicated
>expressions and do expression template magic to compute derivatives and
>stuff at compile time, you can't.
>The options I offered above make all the compile-time information *about
>the full expression* available to Proto so you can compute interesting
>things at compile time.
And I would definitely prefer compile-time as well, but as a user
I would call the the derivative function in a scope that is very far from
where f is defined. Does that matter?
In the syntax you proposed above, what is the "let"?
What are the curly and square brackets for?
If the derivative function is called outside those square bracket, it will
not work?
The declaration of f would be earlier than its definition?
Will I be able to put regular c++ code that is not related to f/g inside the
brackets?
Will I be able to use g outside of the brackets?
Regards,
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