some background(syntax highlighting seems not working properly, sorry for that):
in Java, one can write
Map<String,Collection<String>>xxx, and the compiler won’t get confused about the
>> there because of a trick in the parser. in kotlin however one cannot write
val set:Set<String>=... because the compiler will get confused about
so one might want to use
import Set<String>as SetOfString;val set:SetOfString=..., but it won’t work. however
typealias SetOfString=Set<String> works. this makes me wonder:
- is there a chance that kotlin can enable the use of
val set:Set<String>=...by using the same trick as Java?
the trick is to treat LTEQ(>=) as separate tokens LT(>) and EQ(=) in tokenizer and use LTEQ:=LT EQ in the parser. this also enables the use of
1 > = 0, and it can be disabled if we check for spaces explicitly.
- “typealias”'es functionality is a superset of “import as”'es, namely, every
import M as Ncan be written as
typealias N=M, and
typealias N=M<G>can’t be written as
import M<G>as N.
will kotlin deprecate typealias by allowing import to appear in the middle of the file and support
import M<G>as N, or we can deprecate “import as” in favor of “typealias”?
thx in advance