func Min(a,b T) T {
if a < b {
return a
} else {
return b
}
}
func MinInt32(a,b int32) int32 {
if a < b {
return a
} else {
return b
}
}func Minint(a,b int) int {
if a < b {
return a
} else {
return b
}
}func Minfloat32(a,b float32) float32 {
if a < b {
return a
} else {
return b
}
}............
I want to generate a min func
If you insist on generics-like code generation:
https://github.com/cheekybits/genny/blob/master/README.md
--
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/d/optout.
If we assume a more useful generic task than writing a min function, what's wrong with using code generation?
On Fri, Mar 10, 2017 at 6:14 AM Henry <henry.ad...@gmail.com> wrote:
If you insist on generics-like code generation:
https://github.com/cheekybits/genny/blob/master/README.md
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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+unsubscribe@googlegroups.com.
If we assume a more useful generic task than writing a min function, what's wrong with using code generation?
Hi! You also could use C preprocessor to make such things. I have used it to generate some generics algorithms to increase performance and reduce interfaces overhead. It is not the best approach, but it could be useful and powerful.
FYI: https://github.com/gobwas/ppgo
--
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+unsubscribe@googlegroups.com.
Nothing wrong with it, and nothing wrong with doing it for min and max either. (Though it was a delight to see that animated editing sequence, so for entertainment value that's the way!)I did code generation for my version of Sort and it is 3x-5x faster. It takes intel more than 10 years to make a CPU that is 3-5x faster. Takes just one programmer hour to perfect it with code generation. Nothing wrong with that equation.Let them laugh all they want while you build for speed.Michael
On Fri, Mar 10, 2017 at 4:27 PM, Tyler Compton <xav...@gmail.com> wrote:
If we assume a more useful generic task than writing a min function, what's wrong with using code generation?
On Fri, Mar 10, 2017 at 6:14 AM Henry <henry.ad...@gmail.com> wrote:
If you insist on generics-like code generation:
https://github.com/cheekybits/genny/blob/master/README.md
--
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/d/optout.
--
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.
--
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+unsubscribe@googlegroups.com.