I would say that certainly one would often want to create an API like you've described. What I am reluctant not to support is:
class Foo { static void add(Argumented<Binary<? extends CharSequence, ? extends CharSequence>> functor); } Foo.add(new BinaryFunction<String, String, String>() {}); Foo.add(new BinaryProcedure<String, StringBuffer>() {}); Foo.add(new BinaryPredicate<String, StringBuilder>() {}); The arguments are alike in their "argumentedness" while having different functional interfaces. Convince me this can never be useful, and we can drop the whole thing ;P Matt On Thu, Feb 14, 2013 at 8:55 AM, Jörg Schaible <joerg.schai...@scalaris.com>wrote: > Hi Matt, > > Matt Benson wrote: > > > Once again, an enum wouldn't readily be able to contribute to your > > functor's being able to participate in some method by type signature; > > i.e., I want to support the use case of: > > > > add(Argumented<Binary> somethingThatTakesTwoArguments); > > > > Maybe this isn't a worthwhile goal, but so far I don't see anything else > > that accomplishes this. > > In any case, I wonder if we really want to support type safety for the > argument *types* themselves. > > [snip] > > >> >>> > >> >>> interface Arity { > >> >>> } > >> >>> > >> >>> interface Argumented<A extends Arity> { > >> >>> } > >> >>> > >> >>> interface Unary<A> extends Arity { > >> >>> } > >> >>> > >> >>> interface UnaryFunction<A, T> extends Argumented<Unary<A>> { > >> >>> } > >> >>> > >> >>> > >> >> This is more complicated then having the functors extend Arity, but > it > >> >> makes better use of inheritance from an OO POV I think. > >> >> > >> >> Just to make sure I understand correctly: If I had an UnaryFunction > >> >> that take a Boolean argument and return an Integer I would model this > >> >> as: class MyFunction implements UnaryFunction<Boolean, Integer>, > >> >> right? > > class Foo { > static CharSequence add(UnaryFunction<? extends CharSequence, ? extends > CharSequence> f); > } > > Foo.add(new UnaryFunction<String, String>(){}); > Foo.add(new UnaryFunction<StringBuilder, String>(){}); > Foo.add(new UnaryFunction<StringBuilder, StringBuilder>(){}); > > > This could get really nasty to use. > > - Jörg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > >