"Model 2" prototype status

Kervin Pierre kervin at sludev.com
Tue Sep 1 12:41:06 UTC 2015


Maybe there should be a "valhalla-discuss" which can be used for more
general discussion, leaving "-dev" list for feedback only?

Personally I see value in further discussion around the topics on this
list, but also understand the need to keep the list traffic to a
minimum.  

And "please discuss on the general list" a little more useful and
accommodating a response than "don't discuss here".

Best regards,
Kervin


On Tue, 2015-09-01 at 07:47 +0100, Stephen Colebourne wrote:
> Make sure you've watched the JVMLS videos which may answer some questions:
> https://www.youtube.com/watch?v=uNgAFSUXuwc
> https://www.youtube.com/watch?v=SPhJs4KpJBM
> 
> (they should be considered mandatory for participation in this list!)
> 
> Stephen
> 
> 
> On 1 September 2015 at 03:04, John Altidor <jgaltidor at gmail.com> wrote:
> > Hi Brian,
> >
> > I am new to this mailing list.  My PhD dissertation covered subtyping with
> > variance and Java wildcards extensively, so the questions you raised in
> > this thread are very interesting to me.  I was wondering how you are
> > handling the translational aspects of wildcards and specialized generic
> > methods.
> >
> > Your earlier post asked how to represent List<any> in bytecode.  Since
> > List<any> is a supertype of both List<int> and List<double>, for example,
> > type List<any> should only support operations that can be applied to both
> > List<int> and List<double>.  One such operation is counting the number of
> > elements using method List.size().  Which byte representation would support
> > being able to dispatch List.size() on both an instance of List<int> and an
> > instance of List<double>?
> >
> > It seems such a byte representation would need to be independent of fields.
> >   The number of bytes needed to represent an instance differs among
> > primitive types (e.g. int and double).  As a result, it seems List<int> and
> > List< double> may differ in the number of bytes needed for their fields.
> > In that case, one could not know the number of bytes in the instance of
> > List<any> returned from the following method:
> >
> > List<any> func(int input_num) {
> >   if(input_num is odd)
> >     return new List<int>();
> >   else
> >     return new List<double>();
> > }
> >
> > In addition to type-independent methods such as List.size(), another
> > operation that is type safe to allow on an instance of List<any> is
> > wildcard capture.  Consider the generic method, swapFirstTwo, below that
> > just swaps the order of the first two elements in the input list.  It is
> > type safe to pass an instance of List<any> to this method (because no
> > runtime type error would occur).
> >
> > <any T> void swapFirstTwo(List<T> list) {
> >   T first = list.getAndRemoveFirst();
> >   T second = list.getAndRemoveFirst();
> >   list.addToBeginning(first);
> >   list.addToBeginning(second);
> > }
> >
> > Would two calls to method swapFirstTwo, one with a List<int> as input and
> > the other method call with a List<double> as input, result in two
> > specialized copies of method swapFirstTwo in byte code?  If that is the
> > case, what is the byte representation of method swapFirstTwo when the input
> > is an instance of List<any>?
> >
> > Thank you,
> > John Altidor
> > http://jgaltidor.github.io/



More information about the valhalla-dev mailing list