pele-python / mcpele

Monte Carlo and parallel tempering routines built on the pele foundation
Other
20 stars 5 forks source link

dangerous function defnitions #10

Closed js850 closed 10 years ago

js850 commented 10 years ago

in ConfTest, the test function has the following signature

Array<double> & old_coords, double old_energy, double temperature, 
    MC * mc=NULL) =0;

I think it's dangerous to define mc as optional. If the derived class defines it without mc, but the function is called with mc, I don't think it will actually call the right function.

smcantab commented 10 years ago

this was done to make life easier in the tests, otherwise you need to construct an MC class in all the tests, even those that just test the module alone. But sure, we should go for the safer option

On Fri, Jul 4, 2014 at 12:07 PM, Jacob Stevenson notifications@github.com wrote:

in ConfTest, the test function has the following signature

Array & old_coords, double old_energy, double temperature, MC * mc=NULL) =0;

I think it's dangerous to define mc as optional. If the derived class defines it without mc, but the function is called with mc, I don't think it will actually call the right function.

— Reply to this email directly or view it on GitHub https://github.com/pele-python/mcpele/issues/10.

js850 commented 10 years ago

you can just pass a null pointer to MC

MC * mc = null;