In C, the type is promoted. But this ain't C. No clue what the point is in Go. It would function as a compile-time type-check for "numeric" I guess, but what would be the point?
On Fri, Aug 19, 2016 at 1:32 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > x would already be signed during implicit type inference. The inferred > type is either the one specified in an argument or declaration, or it's the > default type (which is int, thus signed). > > I don't know the answer to your question though. I didn't even know this > existed… > > On Fri, Aug 19, 2016 at 9:54 PM, Rob Thornton <rthornton...@gmail.com> > wrote: > >> What is the purpose of the unary '+' operator? In both C and Go they are >> syntactically correct but neither generate instructions to modify the >> expression. >> >> The '-' operator obviously generates a neg or sub from 0 instruction to >> negate the result by inverting the expression with an add with carry. >> >> I know of no single instruction or pair of instructions to reliably >> ensure any value or expression is always positive so why include this unary >> operator at all? Is there a purpose I'm missing? Or is it just for clarity >> or force an implicit variable to be signed? >> >> As in: >> >> x := +5 >> >> Would this ensure that x must be signed during impicit type inference? >> >> If I read the specification correctly, this would also affect the >> resolution of untyped constants. Is this correct? >> >> -- >> 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. >> > > -- > 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. > -- 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.