On Wednesday, March 7, 2018 at 6:02:58 PM UTC-5, Ian Lance Taylor wrote: > > On Wed, Mar 7, 2018 at 1:36 PM, <di...@veryhaha.com <javascript:>> > wrote: > > > > On Wednesday, March 7, 2018 at 4:26:19 PM UTC-5, di...@veryhaha.com > wrote: > >> > >> get it almost. > >> > >> But I feel > >> > >> var v = float32(1<<s) > >> is a little different to > >> var v float32 = 1<<s > >> > >> > >> For the former one, we think "1" can be assumed as an "int". > >> But anyway, I get the main point of the design. > >> It is just a wording accuracy problem. > >> > > > > On the other hand, any bad if "1" is deduced as an "int" value? > > If we ignore the type context, then > > var v int64 = 1 << s > > fails on 32-bit systems if s > 31 (because 1 is assigned type int, > which is 32 bits, and the shifting a 32-bit value by more than 31 bits > gives you zero). > > If we don't ignore the type context, then in > > var v float32 = 1 << s > > fails because we can't shift a float32. > > We could ignore the type context for float types but not for integer > types, but then the rule is even more complicated. > > Ian > > > Good design. Thanks for the explanation.

> > > >> On Wednesday, March 7, 2018 at 3:59:48 PM UTC-5, Ian Lance Taylor > wrote: > >>> > >>> On Wed, Mar 7, 2018 at 12:54 PM, Volker Dobler > >>> <dr.volke...@gmail.com> wrote: > >>> > Looks suspicious. Without crosschecking the Spec: Might be > >>> > a bug. File an issue? > >>> > >>> It's not a bug. See Andrey's reply. > >>> > >>> Ian > >>> > >>> > >>> > >>> > On Wednesday, 7 March 2018 21:39:32 UTC+1, di...@veryhaha.com > wrote: > >>> >> > >>> >> var s uint = 33 > >>> >> var u2 = float64(1>>s) // illegal: 1 has type float64, cannot > shift > >>> > > >>> > -- > >>> > 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 <javascript:>. > > 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.