Add functions with Annotation Processing

I’m thinking of a new technique in a program I’m trying to complete. The program is centred around linear algebra. My current approach to the program is to use classes, but that’s boring. I am trying to accomplish it with annotations like below.

“`kt fun main() { @Matrix val A = arrayOf( intArrayOf(1, 2), intArrayOf(-2, 0) )

val B = A.inv() // function provided by annotating LOCAL_VARIABLE @Matrix val example = arrayOf( intArrayOf(-3, 0, 1), intArrayOf(4, 9), intArrayOf(3, -2, -1) ) // -> Error: invalid matrix 

} “` I can understand how to create constants using annotation processing and running the generated code file for execution. But how to add extension functions and validate code like the following example.

EDIT If I can accomplish the same easier with Java, then I’m okay with using Java to make my custom annotations.

submitted by /u/cybercoder_naj
[link] [comments]