gsala
04/16/2024, 7:15 AMCLOVIS
04/16/2024, 8:45 AMfranztesca
04/16/2024, 9:19 AMdebug {
val myVariable = expensiveComputation()
log(myVariable) // log is part of the DSL of your library
}
// In debug builds
inline fun debug(block: Debug.() -> Unit): Unit = DebugImpl.run(block)
// In production builds
inline fun debug(block: Debug.() -> Unit): Unit = Unit
In this way you could isolate entire blocks of code that compiled only in debug builds.
The generation of the debug
function can be done with KSP with no need for additional no-op library.gsala
04/16/2024, 9:21 AMCLOVIS
04/16/2024, 9:21 AMinline
route, use a const val DEBUG_ENABLED = false
inside your inline
function, no need for code generation at allgsala
04/16/2024, 9:24 AMephemient
04/16/2024, 5:14 PM