3 ms·
I've been reading this proposal > #19113 Permit signed integers as shift counts: An estimated 38% of all non-constant shifts require an (artificial) uint conve
by nickcw 8y ago
I've been reading this proposal
> #19113 Permit signed integers as shift counts: An estimated 38% of all non-constant shifts require an (artificial) uint conversion (see the issue for a more detailed break-down). This proposal will clean up a lot of code, get shift expressions better in sync with index expressions and the built-in functions cap and len. It will mostly have a positive impact on code. The implementation is well understood.
The proposal as far as I can make out says allow signed integers for shifts but panic if they are negative.
This seems like a step backwards to me pushing checking which the compiler made you do to runtime.
Personally I'd expect a negative shift to shift the other way, but that doesn't seem to be a popular option with the team.
- the_clarence 8y agowhy would someone shift numbers in the first place? I only shift uint8
- infogulch 8y ago> This seems like a step backwards to me pushing checking which the compiler made you do to runtime. No that means this operation is currently unchecked by the compiler: https://play.golang.org/p/nJmaEOkObk1 https://play.golang.org/p/nJmaEOkObk1