On 02/09/13 06:41, H. S. Teoh wrote:
Spot the bug. :)

Ouch!! :-)

The first time I ever implemented random sampling was in C, and it was a version of the same algorithm as in Phobos, but written for the GNU Scientific Library instead. Most of the complex types in GSL are implemented as pointers to "objects" which consist of some kind of data payload plus function pointers that make up the object's API.

So, in that context, it was trivial to use function pointers to manage the sampling algorithm's switch mid-sample from one skip() function to another.

But in D -- risky at least for now, until things like RandomSample are re-implemented as reference types (which they should be).

I suppose one way round this might be to re-implement the to-be-delegated-to function as a free function whose argument is a reference to the calling object, but that's finnicky and not very nice.

Reply via email to