Should native be a modifier?


#1

I'm seeing this as I upgrade to M13...

  Warning:(71, 1) Kotlin: Annotations without ‘@’ are deprecated now


  native fun foo(a: String): Unit = noImpl

I that on purpose? I thought native would be a modifier, since it is in Java.

Rob


#2

There's a discussion of this in another thread here:

https://devnet.jetbrains.com/thread/473086

I’d put it like this - modifier vs annotation is going to seem pretty random in Kotlin because the criteria used are rather subjective, e.g. modifiers are “heavy” and annotations are “light”, and there’s a distinction between the language and the platform that is to my mind a little blurry.

In this case, native is an annotation presumably because it’s a part of the platform, i.e. it does not have an equivalent in Javascript.


#3

Okay, thanks.

(The “native” annotation/modifier does exist in Javascript - but it’s not implemented the same way of course.)

Rob


#4

"native" is a JS-specific thing in Kotlin. A modifier with a somewhat related meaning is "external", it means "a non-abstract functinon with no body". It may be used as an alternative to "= noImpl"


#5

In Js we also have native classes and properties, so will be nice to allow this modifier for them too (in JS)


#6

We'll need to discuss this further. Properties are easy, classes — not so clear