Generics are difficult. Either you end up defining special types with generic operations on them (a la pkg/sort) or you end up reflecting on yourself and burning a lot of performance and adding complexity.
At the worst case, all of them could be implemented and you have a more verbose library.
Maybe the best method of getting feedback in this case is to submit the patch and see what they say. :-)
--alex
Is there any recent news on this?As a new go user, it was very surprising to me to discover that I have to convert my integer to and from a float64 in order to do a simple absolute value. In the end, I ended up implementing the integer version of abs myself, which defeats the whole point of the math package.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Is there any recent news on this?
As a new go user, it was very surprising to me to discover that I have to convert my integer to and from a float64 in order to do a simple absolute value. In the end, I ended up implementing the integer version of abs myself, which defeats the whole point of the math package.
On Monday, August 1, 2011 5:32:33 AM UTC-4, Alex Ray wrote:
Integer.MIN_VALUE, the most negative representable int value, the result is that same value, which is negative."-256, -255, -254, ..., -2, -1, 0, 1, 2, ..., 254, 255
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
As a new go user, it was very surprising to me to discover that I have to convert my integer to and from a float64 in order to do a simple absolute value. In the end, I ended up implementing the integer version of abs myself, which defeats the whole point of the math package.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No need to do the test in Abs(). I agree. But if it was me I'd want to remind people that AbsInt8(-128) will return -128, and so on. (I used 255 before and regret posting while half awake. ;-)
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.