rad
09/12/2024, 12:22 PMif
as they're already used by the language, so you'd need
`if` (variableA eq variableB)
which feels slightly annoying to use. Is there any alternatives (compiler plugin?) or would it just not be possible?
Example of what I'm talking about:
buildGlslShader { // this: GlslShaderContext
glPosition = projMat * modelViewMat * vec4(position, 1.0)
val iColor = ivec3(color.xyz * 255 + vec3(0.5))
`if` (iColor eq ivec3(78, 92, 36) {
// Change some stuff...
}
}
efemoney
09/15/2024, 8:54 AMrad
09/20/2024, 11:56 AMefemoney
09/20/2024, 12:36 PMrad
09/20/2024, 12:38 PMefemoney
09/20/2024, 12:38 PMefemoney
09/20/2024, 12:38 PMMatteo Mirk
10/07/2024, 8:19 AMif
to conditionally execute DSL expressions? Why do you need an alternative ``if`` ?rad
10/07/2024, 10:16 AMMatteo Mirk
10/07/2024, 10:41 AMsealed class GlslDirective {
data object If : GlslDirective() {
operator fun invoke(value: String, setup: () -> Unit) {
TODO("Not yet implemented")
}
}
// more stuff if you want to extend the DSL...
}
then you can use it like:
buildGlslShader {
If("I don't know what eq produces") {
// Change some stuff...
}
}
would this be useful to you?Matteo Mirk
10/07/2024, 10:42 AMMatteo Mirk
10/07/2024, 10:43 AMMatteo Mirk
10/07/2024, 10:54 AMfun GlslShaderContext.If(value: String, setup: GlslShaderContext.() -> Unit) {
// Do something with value
setup()
}
sorry, I've complicated things unnecessarily, I'm not sure what I had in mind... 😄rad
10/07/2024, 11:37 AMMatteo Mirk
10/07/2024, 12:11 PM