On Friday, January 12, 2018 at 2:42:20 AM UTC-5, Axel Wagner wrote: > > What do you mean by "potential type"? There is no such concept. > > The spec <https://golang.org/ref/spec#Constants> is pretty clear, on the > subject, IMO. There is also this blog post > <https://blog.golang.org/constants>. > > The gist is: There are boolean, rune, integer, floating, complex and > string constants. Each of them can be used as values for different sets of > types - for boolean/string constants, the underlying types must be > bool/string. For numeric types, the value (roughly, details in the links > above) must be representable in the target type. This takes care of all the > clearly typed places a constant can appear (e.g. in an expression, a typed > const/var-declaration, a conversion…). Where that's not possible (e.g. an > untyped const/var-declaration, short variable declaration, when used in an > interface{} in an expression…) the default type of the literal (bool, rune, > int, float64, complex128 and string respectively) is assumed. > > What that means is, that you can use any rune/integer/float/complex > literal in any place where any numeric value is used (so anything with > underlying type {u,}int*, rune, float{32,64}, complex{64,128}, uintptr)* > as long as its value can be represented in the target type*. So, for > example this is legal <https://play.golang.org/p/ujaq428Ls6J>, but this > is not <https://play.golang.org/p/Eb1ddSuCmyd>. >
Thanks for information. > > On Fri, Jan 12, 2018 at 8:07 AM, <di...@veryhaha.com <javascript:>> wrote: > >> or >> an untype literal who has a *rune* potential type must also has an *int* >> potential type. >> an untype literal who has an *int* potential type must also has a >> *float64* potential type. >> an untype literal who has a *float64* potential type must also has a >> *complex128* potential type. >> >> >> On Friday, January 12, 2018 at 1:34:08 AM UTC-5, di...@veryhaha.com >> wrote: >>> >>> An untyped rune literal/constant must have a popential int type. >>> An untyped interger literal/constant must have a popential float64 type. >>> An untyped floating-point literal/constant must have a popential >>> complex128 type. >>> >> -- >> 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.