zlacker

[return to "From slow to SIMD: A Go optimization story"]
1. devjam+322[view] [source] 2024-01-24 07:58:34
>>rbanff+(OP)
The author used:

    sum := float32(0)
Over Go's zero-value default initialization e.g.

    var sum float32
A nit stylistically but wondering if there was a good reason to do so?
◧◩
2. abigai+v92[view] [source] 2024-01-24 09:06:33
>>devjam+322
i do the same because i find the var keyword ugly
◧◩◪
3. devjam+Ug2[view] [source] 2024-01-24 10:19:39
>>abigai+v92
Sure, I understand that from the POV of making your code explicit. Personally I have always tended towards, for example:

    var x string
when initializing empty (zero-value) vars, versus:

    x := "hello"
when initializing variables that should hold an initial value.

To me as a Go programmer at least, this is more obvious and intuitive as to the intent of the declaration.

[go to top]