I'm reading the latest chapter of Kotlin in Action...
# announcements
I'm reading the latest chapter of Kotlin in Action, about annotations and reflections. It shows an example where a class (DateSerializer) is passed as parameter of a JsonSerializer annotation. In the example, the DateSerializer class has two responsibilities: serialize and deserialize. Let's assume we change the design and give the annotation a single responsibility: specifying a serializer, which only serializes, and doesn't deserializes. Would it be possible to pass a reference to a function instead of a reference of a class to the annotation. I guess not. But could Kotlin support that, maybe by generating a class wrapping the function at compilation time, and passing that class as parameter in the generated byte-code? Has it been considered in the design of Kotlin?