You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@reef.apache.org by "Julia Wang (QIUHE)" <Qi...@microsoft.com> on 2015/11/02 08:08:08 UTC

RE: Commonly needed Tang functionalities

Hi Dhruv,

Thanks for raising the issues!

For a), Agree we should pursue it as more and more need for it. Can we use named parameter to resolve the issue? Let's discuss about it. 

For b), a type with generic is essentially a template. If we bind an impl<T> to interface<T>, when we call GetInstance<interface<T>>,  can we create an object impl<T> without really know what is T? 

For c), auto generate named parameter for injectable constructors should be doable. But how does the user specify which parameter he would like to bind a value to before build? Or do you mean auto generate named parameter offline? 

Thanks,
Julia
 

-----Original Message-----
From: Dhruv Mahajan [mailto:dhruv.mahajan@gmail.com] 
Sent: Saturday, October 31, 2015 11:19 AM
To: dev@reef.incubator.apache.org
Subject: Re: Commonly needed Tang functionalities

Thanks Markus. I think we should actively pursue a) and b) since to me they are becoming common in each and every application.

Dhruv

On Sat, Oct 31, 2015 at 11:09 AM, Markus Weimer <ma...@weimo.de> wrote:

> Thanks for the notes!
>
> On 2015-10-31 18:48, Dhruv Mahajan wrote:
> > a) Introduce Name parameters for interfaces also.
>
> +1
>
> Have you had a look at REEF-31? As the issue number suggests, this is 
> one of our longest standing feature requests. It is also really, 
> really tricky as it is hard to control where the named instance (and 
> its
> dependencies) end and where the per-injector singletons start again.
>
> > b) Setting default implementation for interface with generic types.
> > Suppose interface is IA<T> currently there is no way to set its 
> > default implementation for tang to be some DefaultA<T> for a general 
> > T.
>
> +1 as well
>
> I don't know enough C# to know whether this is possible, but given its 
> richer type system than Java, something should be possible. Can the C# 
> experts please speak up :-)
>
> > c) I know I am contradicting a) with this point, but introducing 
> > NamedParameter for every Primitive type like int, float, bool etc is 
> > very cumbersome, makes significant increase in number of files
>
> In the early days of Tang, we were discussing the idea of using the 
> name of the constructor parameters themselves as names for the parameters.
> Consider this class:
>
> ```
> class A{
>   @Inject
>   public A(int fooBar){ ... }
> }
> ```
>
> It would automatically create a named parameter `A#fooBar` that can be 
> bound. Would that be easier?
>
> We didn't do it for Java because it required debug symbols, which 
> might have been removed by the compiler. That could lead to very hard 
> to debug problems. Not sure how the same idea would play out in C#.
>
> Markus
>