is mathematical interval notation inherently clash...
# random
h
is mathematical interval notation inherently clashy with typical code syntax?
[1,10)
vs
1 until 10
?
d
I think mismatched braces/brackets/parentheses/etc. are unlikely to be well received even if there’s a basis in the mathematics community for some of them.
h
yeah, that's my worry, though i do think there could be a good demand for number types restricted by range, e.g.
var x: Double by (-3, 4]
and if the interval notation is restricted to delegation in this way, it would likely not be so bad in readability
😱 1
r
@Hullaballoonatic Scala much? 🧌
In all seriousness, Range requirements aren't really something you want in the type definition in general purpose languages.
h
there's little reason to think that a feature existent in a language you don't prefer couldn't be an effective addition to one that you do. refusing to ask such questions out of principle seems silly. unless i misjudge your intent. in which case' i'm sorry
"Range requirements aren't really something you want in the type definition in general purpose languages" i'm intrigued to know why that is?
r
I agree completely with your point in the generic sense, I was talking specifically about this feature.
h
gotcha!
r
Range checking is just a form of data validation, and that can be so nuanced and use case specific (or general and vague), it shouldn't be part of the type system, beyond the fundamental limitations of the type (as computers, unlike math, are finite machines).
h
i can envision that point pretty easily: e.g. if a value is set outside the delegated range, does it default to the closest allowed value, or simply throw an exception?
i appreciate sharing of your thoughts
r
Exactly. I've caught myself in a similar trap on many occasions, where I think "I wish it was smart enough to do..." or "I wish there was a notation for..." and after more consideration realize there's very good reason it shouldn't (and funnily enough it almost always has to do with some form of data validation).
h
is the problem too varied to solve with a single word like
restricted
?
a
Not quite what you're looking for but if you're just interested in the way it looks, you can use something like this plugin: https://plugins.jetbrains.com/plugin/9320-advanced-java-folding The code syntax stays the same but the ide can sugar it
g
Range in your example even not a part of type system (you cannot understand range knowing only type), rather just forced runtime validation Because of this, such validation already can be achieved using classes, just write RangedDouble and use any semantics which you want (crash or use min/max for values outside of type)
t
Maybe programming should have been invented before math. Notation would be so different.
🤔 4
s
we don’t have a think emoji strong enough for that one
2️⃣ 2
1
🤔 2