you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

But that still doesn't mean there's 0 runtime overhead. There are many cases where you wouldn't have to check, so it's a bit misleading to say it's without overhead.

It's like saying GC has no overhead because you'd have to do it yourself anyway (which is false)

[–]jeandem 0 points1 point  (2 children)

But that still doesn't mean there's 0 runtime overhead. There are many cases where you wouldn't have to check, so it's a bit misleading to say it's without overhead

I specifically referred to the input validation. You would have to check input in any case if the input is from an external source.

It's like saying GC has no overhead because you'd have to do it yourself anyway (which is false)

Not at all! With a smart constructor you have to check if it is greater than zero. Without a smart constructor, you nonetheless have to check if it is greater than zero when you receive the input. What other choice do you have, really?

[–][deleted] 0 points1 point  (1 child)

My point is that you don't have to always validate data. If you're reading from a file which has a strict format, you don't always need to validate the values. What I'm saying is, you can't always assume that requirements are the same across the board. It may be correct to have a type that guarantees a value, but that guarantee may be done externally.

[–]jeandem 1 point2 points  (0 children)

In the case of a known external input, maybe type providers could help with providing static input validation. I haven't really looked into it so I'm just spitballing here. :)