# Closeable in common stdlib

**URL:** <https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357>\
**Category:** Language Design\
**Created:** [April 16, 2019, 10:10am UTC](https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357 "2019-04-16T10:10:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![salomonbrys](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/salomonbrys/32/1445_2.png) [@salomonbrys](https://discuss.kotlinlang.org/u/salomonbrys)\
**Post date:** [April 16, 2019, 10:10am UTC](https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357/1 "2019-04-16T10:10:31Z")

</div>

`Closeable` and `Closeable.use` are a very standard pattern.  
So, I am very curious as to why it has not been included in the common standard library.

Closing low-level resources is a common problem, especially in Kotlin/Native.  
Some libraries, such as KotlinX/IO are providing their own `Closeable` / `use`, but I don’t want to depend on KotlinX/IO just for access to `Closeable`!

Therefore, I ended up duplicating `Closeable` / `use` in my own multiplatform libraries, which is by essence a very bad idea ☹.

I searched common Kotlin places (discuss, youtrack, github) and couldn’t find any mention of this.

Any reason why `Closeable` is NOT in the **common** standard library?

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [April 16, 2019, 11:05am UTC](https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357/2 "2019-04-16T11:05:56Z")

</div>

I guess it just hasn’t been implemented yet. Kotlin native is still in experimental access and so are multiplatform projects. There are hundreds of useful classes and interfaces in java and extracting the essentials into common takes time.  
Just create an youtrack-issue ([https://youtrack.jetbrains.com/issues/KT](https://youtrack.jetbrains.com/issues/KT)) and it will probably be added in the future. And I guess if you want to speed it up also create a PR on github 😉

---

<div class="post-metadata">

**Author:** ![salomonbrys](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/salomonbrys/32/1445_2.png) [@salomonbrys](https://discuss.kotlinlang.org/u/salomonbrys)\
**Post date:** [April 16, 2019, 3:40pm UTC](https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357/3 "2019-04-16T15:40:55Z")

</div>

> [@Wasabi375](#):
>
> Just create an youtrack-issue

Here it is 😉 [https://youtrack.jetbrains.com/issue/KT-31066](https://youtrack.jetbrains.com/issue/KT-31066)

---

<div class="post-metadata">

**Author:** ![marcellogalhardo](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/marcellogalhardo/32/10993_2.png) [@marcellogalhardo](https://discuss.kotlinlang.org/u/marcellogalhardo)\
**Post date:** [January 2, 2021, 11:11am UTC](https://discuss.kotlinlang.org/t/closeable-in-common-stdlib/12357/4 "2021-01-02T11:11:49Z")

</div>

Would it be a bad practice to use `DisposableHandle` instead of `Closeable` as it is a KMP compatible and after one year we still don’t have `Closeable` in common KMP? 🤔
