I AM NOT LOOKING FOR SYNTAX SUGGESTIONS. PLEASE DO NOT GIVE ME THEM!
I’ve been experimenting on a private branch of the compiler to allow for explicit variable reuse within a variable declaration.
The idea looks a bit like this:
a, ok := foo()
...
c, *ok := bar()
...
*a, b, *c, d := baz()
Note that ok
was previously declared within the procedure, so marking it with *ok
in another variable declaration means it would reuse the previous declaration of ok
rather than result in an redeclaration error.
I know a lot of people want this however the more and more I think about it, the more I think it’s probably a code smell in the first place. I’ve grepped a lot of my code to see where this pattern happens a lot and it’s always bodges and unit @test
s, rather than anything useful.
I’d love to see examples where this “idiom” would be useful because I want my gut to be proven wrong about it being a bad idea and a “code smell”.
I AM NOT LOOKING FOR SYNTAX SUGGESTIONS. PLEASE DO NOT GIVE ME THEM!