logoalt Hacker News

andrewjf • last Sunday at 9:37 PM • 4 replies • view on HN

Yeah but why wouldn't "x" be a type that could only represent positive integers?


Replies

grg0 • last Sunday at 9:41 PM

I would like Ada-style integer types too, but I don't strictly know how those are implemented. Are you suggesting invariants should also be given at the type level?

account42 • yesterday at 2:59 PM

There is no builtin integer type that guarantees x > 0. I agree that adding such a type (and more general, range guarantees at the type system level) would be very useful.

Joker_vD • last Sunday at 10:06 PM

Have you seen the wave of recent Whatever2Shell CVEs? Several of them happened precisely because "a type that could only represent positive integers" was used for the sizes.

➕ show 1 reply
kevin_thibedeau • last Sunday at 9:40 PM

They really should just copy Ada rather than this whizbangery.

➕ show 1 reply