spxbhuhb / adaptive

Consolidated full-stack application development library for Kotlin
Apache License 2.0
0 stars 0 forks source link

Function variants and syntactic sugar #15

Closed toth-istvan-zoltan closed 2 weeks ago

toth-istvan-zoltan commented 1 month ago

Plan function variants and/or syntactic sugar.

Syntactic sugar:

The fragment should have only a String in the state and the compiler should use the body of the function to set the value, the anonymous function should be removed.

This would require some checks, such as no function references allowed.

@Adaptive
fun someFun(@AdaptiveSugar valueFun : () -> String) {
    // ...
}

Variants:

@AdaptiveVariant
fun someFun(i1 : Int, i2: Int) = someFun(i1 + i2)

@AdaptiveVariant
fun someFun(i : Int) = someFun(i, "Hello World!")

@Adaptive
fun someFun(i : Int, s : String) {
    // ...
}
toth-istvan-zoltan commented 2 weeks ago

Moving the classes inside the functions solved the variant question.

I'll put the syntactic sugar on the shelve for now.