Voldemort Types in D

Sean Kelly sean at invisibleduck.org
Wed May 9 10:11:59 PDT 2012


On May 9, 2012, at 7:30 AM, Andrei Alexandrescu wrote:

> http://www.reddit.com/r/programming/comments/telhj/voldemort_types_in_d/


One thing:


"and then use g. I know what you're thinking — use typeof and declare another instance of RandomNumberGenerator:

  auto g = generator(4);
  typeof(g) h;

Sorry, that won't work, the compiler will not allow a Voldemort Type to be instantiated outside of its scope (the technical reason is it has no reference to the seed local variable)."


If the struct were made static and given a ctor that seed were passed to, I imagine it would work, yes?


More information about the Digitalmars-d-announce mailing list