This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wildcards in parameterized types?


On Oct 6, 2011, at 9:16 PM, Per Bothner wrote:

On 10/06/2011 04:32 PM, Jamison Hope wrote:
On Oct 6, 2011, at 2:59 PM, Per Bothner wrote:

I think that's only part of it. The first thing IMO to "fix"
is the type of com.example.SomeClass, so that it is (in Kawa syntax)
java.lang.Class[com.example.SomeClass] so the type matches the
type of the Java expression com.example.SomeClass.class.

Presumably the ParameterizedType instance would be coerced to the
correct type when passed to a function expecting a Class instance.

Careful. I think you're mixing reflective levels here,

Yeah, probably.


The expression java.lang.Object evaluates to a *value* which
the same as the Java expression java.lang.Object.class
(or Class.forName("java.lang.Object")).  This will not change.
What should is the *compile-time type* of the expression.
I.e. when given the QuoteExp that represents java.lang.Object,
what will getType() return?  Will it return a ClassType
as today (Specifically Type.javalangClassType) or will it
return a ParameterizedType instance? The latter seems correct,
but does not change the runtime value or how it is coerced.

OK, I think I get it now. So the *value* of the literal java.lang.Object will continue to be java.lang.Object.class, but the *type* will be java.lang.Class[java.lang.Object]. Which is not saying that the literal java.lang.Object will mean the same as the literal java.lang.Class[java.lang.Object] (which is of type gnu.bytecode.ParameterizedType).


Anyway, as far as wildcards go, I don't have any good suggestions for good syntax to cover all the cases. Foo<?> => Foo[?] seems natural, and Foo<? extends Super> => Foo[Super?] seems sensible, but what to do about Foo<V extends Super> (which binds V to a type), or Foo<? super Sub>... I don't know. What do other JVM languages do (Scala, Clojure, ...)?

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]