Type wrapping blockers

Don nospam at nospam.com
Tue Oct 5 07:25:31 PDT 2010


Steven Schveighoffer wrote:
> One of the good goals of D I think is to be able to automatically 
> encapsulate a type, and all its attributes/functions, in order to 
> slightly alter the functionality.  I think this is probably a pattern, 
> but I don't know what it is (Interceptor?).
> 
> One of the best methods to wrap a type is to use opDispatch.  But there 
> are some problems that block this.  It might be good to get a bug report 
> that gathers these together.  I have one that I just ran into -- IFTI 
> and literals.  Basically, if you have a function:
> 
> void foo(short x);
> 
> you can call foo(1) no problem.
> 
> But if you *wrap* the type that contains foo, you cannot use opDispatch 
> to implement foo(1), because IFTI treats 1 as an int.  So what you get 
> is an instantiation of opDispatch like this:
> 
> opDispatch!("foo", int)(1)  Which then cannot call foo, because you 
> cannot cast int to short.

That is bug 4953.


More information about the Digitalmars-d mailing list