On Monday, 31 March 2014 19:06:47 UTC-4, Tim Boudreau wrote:
>
> On Mon, Mar 31, 2014 at 3:17 PM, Christian Gruber 
> <[email protected]<javascript:>
> > wrote:
>
>> On 31 Mar 2014, at 11:45, Tavian Barnes wrote:
>>
>>  I was thinking the priorities would constitute an absolute ordering for 
>>> the
>>> entries (i.e., duplicate priorities prohibited).  Then they have a unique
>>> ordering even split across modules.
>>>
>>
>> Ah.  That could work, though I can see it being one of those features 
>> that poor planning will clobber nastily.  But it's also an "expert" feature 
>> in a way, so wise users will space out their priority key-space so there is 
>> room to insert.
>
>
> Exactly.
>
> The comesBefore/comesAfter constraint type of thing is more aesthetically 
> elegant, but would mean that a module that wanted its entry to come after 
> one from another module would have to expose the type of its contribution, 
> which breaks encapsulation.  So integers and some advice about spacing them 
> are the way to go.
>
> -Tim
>
 
You could also use rationals to allow unlimited subdivision, but that's 
probably confusing.  doubles could also work, as could decimal strings or 
something.  That may be taking it too far.

The comesBefore/After constraints could take a Module subclass rather than 
the implementation type, thus keeping encapsulation but adding some 
coupling between modules (or, in a sense, making the existing coupling 
explicit).  Something like this:

ListBinder<Snack> listBinder = ListBinder.create(binder(), Snack.class);
listBinder.orderBefore(OtherModule.class);
listBinder.addBinding().toInstance(new Twix());
...

It's may be hard to give helpful error messages if the topological sort 
fails though.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to