bearophile wrote:
grauzone:
That wasn't very explicit. Anyway, we need int.min for, you know, doing useful stuff.

Like for what? Have you used a Lisp? Their tagged integers show that a smaller 
range is fine. And I'm just talking about 1 value in 4 billions, I don't think 
you will miss it much. And it's a value that has no symmetric positive.

It's fine for Lisp because any Lisp I've ever seen auto-upgrades out-of-range integers to (heap-allocated) bigints.

PS: I'd prefer "checked" math operations (as in C#, I think) over int.nan. Overflows or illegal operations would just trigger exceptions.

I'll do my best to have them in LDC (LLVM supports them already!), it's 
probably the only new feature I'll ask to LDC developers. If necessary I may 
even create a personal version of LDC that has this single extra feature.

I'd like to point out you don't need a new built-in type (or changes to a existing one) to use those LLVM intrinsics with LDC. Just import ldc.intrinsics, define a struct MyInt and overload operators on it using llvm_sadd_with_overflow and friends.

That doesn't work for external libraries of course, but those should be free to handle overflow situations and undefined operations however they want without having to worry about int.nan...

Reply via email to