I'm not sure if you are still interested in details or not. Assuming you ask the question "why" it works differently, one of the short answers, assuming some basic background knowledge on your part about compilers and programming language implementation details: similar, but different concepts->different restrictions->different rules->different implementations. You might want to take a look at the different precision requirements in the spec for both constants and variables. You maybe also want to think about the costs and benefits to having the compiler and the compiled code work this way or if you are really curious, think about how the same rules with the same semantics could be implemented for both constants and variables, I'm not sure, but iirc there was some discussion pre 1.0 about some of the aspects of constants, you might want to take a look at the mailing list archives.
Another short answer: the expressions just look similar, these aren't the same. (+1: if you quote code, please use links to the playground or alternatively just no html in emails.) On 5/21/19, djad...@gmail.com <djad...@gmail.com> wrote: > > Thanks all for comments, > > for me confusion is that > int( some_float_var) > > works, and surprisingly > int( some_float_constant) > > does not. > > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/50e711ce-6e11-43d7-8e7f-46275e141bdb%40googlegroups.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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CA%2BctqrqptDtcK83AOcacfYc%3DNCdDHrd2cJXff%2B1tu81SiiV%3DoQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.