Recording object states
Simen Kjaeraas
simen.kjaras at gmail.com
Mon Oct 3 07:52:30 PDT 2011
On Sat, 01 Oct 2011 17:47:10 +0200, Andrej Mitrovic
<andrej.mitrovich at gmail.com> wrote:
> I just thought it's really cool how D makes this possible and very
> easy to do. Check it out:
>
> http://codepad.org/yA8ju9u0
>
> I was thinking of using something like this in code samples for a
> library (e.g. CairoD), where a Recorder object like this would capture
> the states of some shape and then generate a series of images on how
> that shape changes over several function calls. And this could easily
> be injected into HTML documentation.
>
> Thanks to opDispatch I would only have to rewrite a small portion of
> my sample code, replacing "Shape" ctor calls with Recorder(Shape())
> calls.
You might want to consider a template constraint on opDispatch:
auto opDispatch(string method, Args...)(Args args) if
(is(typeof(mixin("t."~method))))
--
Simen
More information about the Digitalmars-d
mailing list