# Preprocessor to avoid code-duplication for primitive type specialization

**URL:** <https://discuss.kotlinlang.org/t/preprocessor-to-avoid-code-duplication-for-primitive-type-specialization/16686>\
**Category:** Language Design\
**Created:** [March 11, 2020, 4:27pm UTC](https://discuss.kotlinlang.org/t/preprocessor-to-avoid-code-duplication-for-primitive-type-specialization/16686 "2020-03-11T16:27:46Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![hanslovsky](https://avatars.discourse-cdn.com/v4/letter/h/eb8c5e/32.png) [@hanslovsky](https://discuss.kotlinlang.org/u/hanslovsky)\
**Post date:** [March 11, 2020, 5:54pm UTC](https://discuss.kotlinlang.org/t/preprocessor-to-avoid-code-duplication-for-primitive-type-specialization/16686/7 "2020-03-11T17:54:15Z")

</div>

Thanks, that clarified it a lot. My idea was something like the scala-like specialization annotation that you mention and is also discussed in [Primitive Type Specialization - #5 by furunkel](https://discuss.kotlinlang.org/t/primitive-type-specialization/11022/5). I understand that to implement it as an official language feature, more thought will have to go into it. A fairly naive compiler plugin that generates only specializations by copy&replacing with primitive types as specified by the programmer (and not by the downstream caller) would definitely satisfy my own needs.

Update: Is there a way to mark a post as solution for the thread? I have seen it in other discourse forums but I cannot find it here.

---

_[View the full topic](https://discuss.kotlinlang.org/t/preprocessor-to-avoid-code-duplication-for-primitive-type-specialization/16686)._
