This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ wrapping


On Mon, 2004-04-12 at 10:11, linas@austin.ibm.com wrote:
> 
> Sure. Pretend it was c not c++:
> 
> class GSLSolver 
> {
>    public:
>       virtual void declare_func_to_solve (double (*f)(double));
>       virtual double get_solution(void);
>   private:
>       double (*fs)(double);
> };

This is no good because there is no place to put any underlying
state (parameters) for the function. I see that as the main
problem with function pointers.

By the way, one way to get around this is to have an implementation
of 'lambda', so you can bind other args to create a function with
the signature you want. There are some C++ libraries that provide
something like this. However, even if we had a real and true
standardized lambda in C++, I would not consider it a complete
solution. C++ programmers are used to hiding their parameters
in class scopes, which has come to make sense to us all;
functional programming is just a completely different way to
think about those "other parameters", and it does not interact
in any obvious way with class data members.


-- 
Gerard Jungman <jungman@lanl.gov>
Los Alamos National Laboratory


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]