spxbhuhb / z2-pre

Libraries for Kotlin Multiplatform development
Apache License 2.0
1 stars 0 forks source link

[Schematic] Replace the current field definition with builder syntax #5

Open toth-istvan-zoltan opened 8 months ago

toth-istvan-zoltan commented 8 months ago

The current field definition syntax looks like:

class A : Schematic<A> {
    var i by int(min=12, max=24)
}

This is hard to read and problematic as we add more customisation features.

Future syntax:

class A : Schematic<A> {
    var i by int {
        constraint min 12 max 24
        constraint validator { it % 2 == 1 }
        attribute label "I"
        attribute hint "Must be odd."
        attribute doc "This is a number which must be greater than or equal to 12 and lesser than or equal to 24."
    }
}
toth-istvan-zoltan commented 8 months ago

This change can be done in the following ways:

No compiler support

Pros:

Cons:

Builder Verification

Pros:

Cons:

Full Builder Translation

Pros:

Cons: