Imagine a language that supports subtyping, but has no pointers. To allow foo(Animal) to be called with a Dog as an argument, the compiler generates a version of foo that takes Dog as an argument but otherwise is identical to foo(Animal). It does this by need, not for every conceivable method call. I expect you can see that this works. I believe something like that can be used to elide garbage creation in the JIT, though I can't find any reference to say whether it's in Hotspot now or only a possibility in future.
Also, why does List<float> work in C# then? On Mon, Dec 6, 2010 at 11:44 PM, Kevin Wright <[email protected]>wrote: > A reference to a float can hardly hold a double if you can't have a > reference to a float in the first place! (this is why you can't have a > List<float>) > On 6 Dec 2010 23:39, "Ricky Clarkson" <[email protected]> wrote: > > How does a reference affect it? > > > > On Mon, Dec 6, 2010 at 11:31 PM, Kevin Wright <[email protected] > >wrote: > > > >> Liskov means that you can write code which depends on the exact rounding > >> behaviour of a float, and it would fail if working with a double. The > types > >> are not transparently substitutable. > >> > >> This isn't a subclasses relationship, nor can it be - given that > primitives > >> aren't held by reference. > >> > >> The specification is, quite simply, misleading > >> On 6 Dec 2010 23:24, "Miroslav Pokorny" <[email protected]> > >> wrote: > >> > Liskov principal means a long can stand in for a int and teh caller > will > >> > work unmodified w/ both. Given some conversion is required between the > >> two > >> > and the bit patterns are different (eg byte -> double), there is no > >> > substitution there is only conversion. One needs different bytecode to > do > >> > whatever with an int and all the other primitives ignoring boolean and > >> other > >> > different/weird cases. > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > Groups > >> "The Java Posse" group. > >> > To post to this group, send email to [email protected]. > >> > To unsubscribe from this group, send email to > >> [email protected]<javaposse%[email protected]> > <javaposse%[email protected]<javaposse%[email protected]> > > > > >> . > >> > For more options, visit this group at > >> http://groups.google.com/group/javaposse?hl=en. > >> > > >> > >> -- > >> You received this message because you are subscribed to the Google > Groups > >> "The Java Posse" group. > >> To post to this group, send email to [email protected]. > >> To unsubscribe from this group, send email to > >> [email protected]<javaposse%[email protected]> > <javaposse%[email protected]<javaposse%[email protected]> > > > > >> . > >> For more options, visit this group at > >> http://groups.google.com/group/javaposse?hl=en. > >> > > > > -- > > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<javaposse%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
