Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does header/impl keyword mean in kotlin?

Tags:

kotlin

Just moments ago when I was exploring the Kotlin github repo, I found something interesting: Kotlin now seems to have a header keyword.

CollectionsH.kt:

 open header class ArrayList<E> : MutableList<E> {

 //...

 header inline fun <reified T> Array<out T>?.orEmpty(): Array<out T>

What does it mean? Is it some public available feature or a internal feature to help stdlib development?


EDIT: There seems to be a impl keyword that work in conjunction with header. What's that?

like image 259
glee8e Avatar asked Mar 09 '17 14:03

glee8e


1 Answers

UPDATE 2:

Multiplatform project support has been released.

  • Link to the announcement
  • Multiplatform application for KotlinConf 2017

UPDATE 1:

The impl and header keywords have been replaced by actual and expect in the preview release of multiplatform projects for Kotlin.

The official documentation can be found here or at this GitHub permalink


It was talked about in this video at 14:28.

From the slides: Slide #14

Basically, header will be used when writing interfaces for modules that work across multiple platforms (JVM, JS, and Native). Theimpl keyword will be used when writing an implementation for a specific platform.

like image 51
Aro Avatar answered Oct 13 '22 20:10

Aro