2013/7/3 Durchholz, Joachim <[email protected]>

> > I'm not advocating making everything final. I'm saying that making
> > any recursive / self-bound *terminator* final is the only way to
> > *guarantee* that the contracts introduced by the recursive
> > self-bound in the first place won't be broken.
>
> Ah right. I was so occupied with sorting out the point with covariance and
> contravariance that that got out of sight. (I first thought that text were
> saying "covariance is a property of generics"; I had to re-read the text
> thrice to really see that "of course generics are just one way to have
> covariance.)
>
> I also got misled by the title. It's talking about "dangers", which led me
> towards looking for type holes. It's just that I don't see any - I have to
> admit I'm still losing track of what parts of the post describe just
> preliminary explanations and what parts define the conditions under which a
> problem pops up, and I've been missing any argument how the conditions are
> responsible for the problem.
> At least I can say that Java does not make Foo<Subtype> assignable to
> Foo<E extends Supertype>, or Bar extends Foo<AnyType> assignable to
> Foo<AnyType>, so the usual "parameter covariance makes a subclass SO not a
> subtype" problem is not present. (Unsurprisingly. Gilad Bracha and the
> other guys who designed Java's generics are widely-recognized type system
> experts.)
>
> So... I'm not seeing a type hole.
> What I do see is an annoying type error message from the compiler if you
> try to subclass AppleContainer with GalaContainer and want
> GalaContainer.container() have return the GalaContainer.
> But that's easily fixable! Just override container() to return
> GalaContainer. No relationship to generics at all, it's a standard problem
> in subtype definitions.
>
> ... I just hope I'm not overlooking something glaringly obvious :-)


It's not obvious. It's subtle. You cannot actually create a meaningful
GalaContainer type, because a GalaContainer will not contain Gala objects,
it will contain Apples, which defeats its purpose. Apples terminate
meaningful subtype inheritance without enforcing that termination. All
subtypes of Apple will no longer fulfil the intent of AnyObject<O extends
AnyObject<O>> and AnyContainer<E extends AnyObject<E>>.

... which leads again to my original claim that self-bounds in generics are
a dangerous field because they can cripple a type hierarchy, which cannot
be fixed easily if adhering to semantic versioning.

Anyway, I feel that this discussion starts getting a bit off-topic for the
jOOQ User Group... :-)
The various .sql() methods can be added to a DSL API without using
recursive generics.

Cheers
Lukas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to