News for hackers. Stuff that matters.
Re:5 Weeks of Go by luriel on Wednesday May 23, 2012 @01:27PM (#4014139)
"garden-variety" int wont be int32 forever.
Re:5 Weeks of Go by 4ad on Wednesday May 23, 2012 @01:33PM (#4014190)
Indeed, in fact that's why rune has been added to the language little more than 6 months ago. Now that rune is used instead of int for representing unicode code points, int can be extended to 64 bit.
Re:5 Weeks of Go by taliesinb on Wednesday May 23, 2012 @01:35PM (#4014209)
That's true, and it will probably change fairly soon, but there are a whole range of safe integer to float casts that will still exist even if int changes from int32 to int64.

And these safe casts should be transparent so that people who regularly do things with floats don't feel like second class citizens in the language.

Re:5 Weeks of Go by 4ad on Wednesday May 23, 2012 @01:45PM (#4014263)
The check cannot be made at compile time, only at run time, and even if it were possible to make the check at compile time it would still be a bad idea. At some point in the program's 20 year old life time, someone will decide that a number N used somewhere in the program has to become N+1, and N+1 doesn't work. It would be unacceptable for such a trivial change to break the program's compilation, and for a number to carry so much hidden state and meaning.
Re:5 Weeks of Go by taliesinb on Wednesday May 23, 2012 @02:19PM (#4014480)
I don't understand why people are so afraid of compile time errors. They're great! They help us write code and reason about it.

If someone changes some ossified piece of code, and that has the effect that it makes an automatic cast semantically dangerous, I'd be extremely grateful if the compiler scolded me with a helpful error message.

Re:5 Weeks of Go by taliesinb on Wednesday May 23, 2012 @02:07PM (#4014404)
I'm not sure what you mean by "The check cannot be made at compile time, only at run time". Are you talking about a language other than Go? Go is statically typed.

edit: I've been talking about compile time errors that prevent potentially dangerous implicit casts from happening. I think you're talking about something else.

Re:5 Weeks of Go by ori_b on Wednesday May 23, 2012 @02:09PM (#4014422)
If int64 is the default type for int, then any int will be able to contain values not representable as a float64 (you'd need a float80 or float128 to make it work). To safely convert, a run-time check will be needed.