The future of UDAs.

Max Samukha maxsamukha at gmail.com
Wed Nov 28 15:57:12 PST 2012


On Wednesday, 28 November 2012 at 22:46:47 UTC, Walter Bright 
wrote:
> On 11/29/2012 3:23 AM, Max Samukha wrote:
>> That is a problem for anyone who builds a library for general 
>> use.
>
> I don't see how any library for general use would be importing 
> user modules, so there shouldn't be a circular import 
> dependency between user modules and library modules.

module library;
shared string[] registry;

mixin template RegisterSomething(alias something)
{
     shared static this() { registry ~= something.stringof; }
}

----
module user_b;
import user_a;
import library;

int y;
mixin RegisterSomething!y;

----
module user_a;
import user_b;
import library;

int x;
mixin RegisterSomething!x;


We have:
         library
      /            \
user_a <-circle-> user_b

That is why I am saying that we are imposing a certain structure 
(no circular imports) on the user of our library. For example, if 
the user prefers (or has to use, in my case) a class-per-module 
structure, circular dependencies between user modules are 
practically unavoidable and the library cannot be used there.






More information about the Digitalmars-d mailing list