Number Dimensions I'm currently investigating the...
# language-proposals
g
Number Dimensions I'm currently investigating the Kotlin-CSS-Wrapper (https://github.com/JetBrains/kotlin-wrappers/tree/master/kotlin-css), and during migration of my CSS to that wrapper, I experienced, that using this DSL has some drawbacks over plain CSS: Dimensions of Numbers cannot be written that well as with plain CSS. So it would be really useful to have the possibility for giving a Number a dimension like this:
Copy code
dimension val Int.px: MyDimensionedNumber  get() = MyDimensionedNumber(this, "px")
dimension operator val Int.unaryRem: MyDimensionedNumber  get() = MyDimensionedNumber(this, "%")
Then instead of using things like:
Copy code
100.px
100.pct
This can be done:
Copy code
100px
100%
🤔 1
Maybe this is even too narrowed down, and can be superseded with a more general feature.
o
I don’t think omitting the dot improves the code so much, that we need a special language feature to support this. Not even mentioning that it is almost impossible to have good language rules for suffix operators and functions.
g
Form a developers perspective I can totally understand that. But from the perspective e.g. form a WebDesigner, which works with the Kotlin-CSS-DSL, it is more intuitive to use such a language without the need of a dot between the number and the dimension. Actually, the dot itself maybe isn't the biggest issue, but also taking away the support to use "%" as prefix in a number is quite some issue (for non technical people) and makes the DSL not that friendly to use as plain CSS.
o
Well, Kotlin is not CSS, and not HTML, so you can’t write
<div>
but have to use kotlinx.html and write as
div { }
. If we were to support all syntaxes of all languages I don’t think it would be comprehensible language.
g
true