Feature request: Add support for custom operators (original) (raw)
March 20, 2025, 11:34am 1
Hello mates!
In Swift it’s possible to create custom operators like this:
prefix operator |
postfix operator |
infix operator | : AdditionPrecedence
But in Kotlin you can only use predefined set or letters like ‘I’ for operators.
It will be incredible if you add support for any operators in the future
So it will be possible to make the translation of ‘The Wand: Declarative programming language for error-free coding’ also to Kotlin. And we will support all actual mobile ecosystems.
kyay10 March 20, 2025, 11:55am 2
This might be unlikely to be added.
In the meantime though, you might wanna check out my IntelliJ Plugin that uses folding regions to have the code display as if those were operators.
For instance:
@Pretty("~")
@Prefix("", "")
fun inv(foo: Foo)
@Postfix("", "")
val Int.c
@Pretty("&")
infix fun Int.and(other: Int)
inv(foo) // Displays as ~foo
5.c // Displays as 5c
5 and 10 // displays as 5 & 10
alkozin March 24, 2025, 3:27pm 3
Thanks for your plugin- looks amazing. Great work, right thing that I need