On Wednesday, 30 August 2017 at 18:20:46 UTC, Jean-Louis Leroy wrote:
On Wednesday, 30 August 2017 at 18:05:38 UTC, jmh530 wrote:
On Wednesday, 30 August 2017 at 17:24:55 UTC, Jean-Louis Leroy wrote:

We had a discussion about automating the call to updateMethods but I don't think that anybody thought of putting it in registerMethods. It might work. I'll look into it. Thanks for the suggestion...

Ali had suggested something similar[1]. I think your concern was that it would get called multiple times, but shared static module constructors runs once a program (static module constructor runs once per thread).

[1] http://forum.dlang.org/post/okljj1$ktb$1...@digitalmars.com

Ah yes...So the problem is that registerMethods emits static ctors that fill data structures representing the methods and the specializations. They have to run - all of them - before updateMethods. Thus, sadly Q's suggestion won't work.

Yes I remember now...even if we arrange to put the call to updateMethods in its own static ctor, coming after all the other static ctors, we don't know if there will be more modules with more methods afterwards. So we would have to do the updateMethods work each time, lest this module is the last. And updateMethods is costly: not only does it figure out all the dispatch tables, it also calculates a perfect hash (if @mptr is used) using a random algorithm.

Reply via email to