Re: [go-nuts] feature request: allow literal digit underscore grouping
I should've realized go automatically coerced float constants to ints. Which is worse but never mind :-) > On Jun 22, 2016, at 8:57 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Wed, Jun 22, 2016 at 5:54 PM Bakul Shahwrote: > > That can be dealt with an output format. Just as the hex or octal or the "e" > input format is lost. > > > ... in Go there is a slight inconsistency: 1e6 is an int but 1e-6 is a > > float. > > The literals 1e6 and 1e-6 are both untyped floating point constants. > > > -- > -j -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
On Wed, Jun 22, 2016 at 5:56 PM Andy Balholmwrote: > The same is true of brace styles :-P. Brace style is a matter of preference. Wrong digit grouping in a given place on Earth is wrong, not less preferred. -- -j -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
On Wed, Jun 22, 2016 at 5:54 PM Bakul Shahwrote: That can be dealt with an output format. Just as the hex or octal or the "e" input format is lost. > ... in Go there is a slight inconsistency: 1e6 is an int but 1e-6 is a float. The literals 1e6 and 1e-6 are both untyped floating point constants. -- -j -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
The same is true of brace styles :-P. But my point is that by not allowing digit grouping, Go avoids style debates on that issue. The grouping could have been standardized with gofmt, but as it is, it is standardized by the compiler to a format that is universally understood (no grouping). Andy -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
That can be dealt with an output format. Just as the hex or octal or the "e" input format is lost. With respect to the "e" notation Go seems to be an exception. Perhaps the sole one? Other prog languages I have used treat eas a floating pt. even in Go there is a slight inconsistency: 1e6 is an int but 1e-6 is a float. I find 1_000_000 clearer than 1e6. Not a big deal either way. > On Jun 22, 2016, at 8:17 AM, Michael Joneswrote: > > Sorry, I sent that too soon. > > One argument against underscores in numbers and other discardable syntax is > the tooling in Go to parse and regenerate go code, as in gofmt. It may be > more complicated to keep the “original input format” around and that is a > pretty good argument—unless that is already there for input values in hex. > > Michael Jones > michael.jo...@gmail.com > >>> On Jun 22, 2016, at 8:14 AM, Michael Jones wrote: >>> >>> https://github.com/golang/go/issues/42 >> >> Michael Jones >> michael.jo...@gmail.com >> >>> On Jun 22, 2016, at 7:29 AM, Roger Pack wrote: >>> >>> Could you drop me a link to the discussion by chance? Seems this >>> feature is actually a reasonably common request :) > > -- > 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
Actually, the mention of gofmt brings up the issue of consistent formatting. If underscores in numbers were allowed, gofmt should automatically insert them for all numbers over a given length, and remove them for shorter numbers. Otherwise it would just be another opportunity for inconsistency, like indentation. Andy -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
Sorry, I sent that too soon. One argument against underscores in numbers and other discardable syntax is the tooling in Go to parse and regenerate go code, as in gofmt. It may be more complicated to keep the “original input format” around and that is a pretty good argument—unless that is already there for input values in hex. Michael Jones michael.jo...@gmail.com > On Jun 22, 2016, at 8:14 AM, Michael Joneswrote: > >> https://github.com/golang/go/issues/42 > > Michael Jones > michael.jo...@gmail.com > >> On Jun 22, 2016, at 7:29 AM, Roger Pack wrote: >> >> Could you drop me a link to the discussion by chance? Seems this >> feature is actually a reasonably common request :) > -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
> https://github.com/golang/go/issues/42 Michael Jones michael.jo...@gmail.com > On Jun 22, 2016, at 7:29 AM, Roger Packwrote: > > Could you drop me a link to the discussion by chance? Seems this > feature is actually a reasonably common request :) -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
Could you drop me a link to the discussion by chance? Seems this feature is actually a reasonably common request :) On Tue, Jun 21, 2016 at 12:47 PM, Michael Joneswrote: > I asked for this a while back ("drop underscore between digits as in Ada") > and the answer was no. I try to ask just once. > > This was shut down without much discussion at > https://github.com/golang/go/issues/42. > > I agree that it's a nice feature. > > By the way, though, one nice aspect of Go is that because of how > untyped constants work you can write integers using scientific > notation: > > for i := 0; i < 10e6; i++ { > // ... > } > > This is exactly the same as if you had written 1000. > > (I don't think you'd want to do this in C or Java because, although it > would "work", 10e6 is a floating point number and so i would be > converted to a double for comparison. I am not an expert in those > languages, though, so someone can correct if I'm wrong here.) > > On Tue, Jun 21, 2016 at 8:44 AM, Roger Pack wrote: >> I found recently when doing some language comparisons >> >> In a few other languages (ruby, java, etc.) underscores within numeric >> literals to make them more readable, ex: >> >> 10_000_000.times do >> ... >> end >> >> go ex: >> >> for i := 0; i < 1000; i++ { >> ... >> } >> >> I find it helps readability, and think it would be a nice addition to the >> language (or some way to group digits, perhaps there already is one?). >> Consider this a feature request (go 2.0 or what not). >> Cheers. >> -roger- >> >> -- >> 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
On Wed, Jun 22, 2016 at 6:50 AM, Manlio Perillowrote: > On Wed, Jun 22, 2016 at 3:35 PM, Henrik Johansson > wrote: >> Really? > > Yes. > The problem is that many people coming from C like languages may > incorrectly assume that i is a floating point number. This doesn't strike me as a good reason to avoid writing numbers as 1e6 or whatever. Go is a relatively simple language. It's reasonable to expect people using Go to learn the language. Ian -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
Really? I find that counting digits in large numbers is harder, for me at least, than expected. The scientific notation is sweet. On Wed, Jun 22, 2016, 14:57 Manlio Perillowrote: > Il giorno martedì 21 giugno 2016 18:35:13 UTC+2, Caleb Spare ha scritto: >> >> This was shut down without much discussion at >> https://github.com/golang/go/issues/42. >> >> I agree that it's a nice feature. >> >> By the way, though, one nice aspect of Go is that because of how >> untyped constants work you can write integers using scientific >> notation: >> >> for i := 0; i < 10e6; i++ { >> // ... >> } >> >> This is exactly the same as if you had written 1000. >> >> (I don't think you'd want to do this in C or Java > > > I would not do this even in Go, since it makes the code less readable IMHO. > > > [...] > > > Manlio > > -- > 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
Il giorno martedì 21 giugno 2016 18:35:13 UTC+2, Caleb Spare ha scritto: > > This was shut down without much discussion at > https://github.com/golang/go/issues/42. > > I agree that it's a nice feature. > > By the way, though, one nice aspect of Go is that because of how > untyped constants work you can write integers using scientific > notation: > > for i := 0; i < 10e6; i++ { > // ... > } > > This is exactly the same as if you had written 1000. > > (I don't think you'd want to do this in C or Java I would not do this even in Go, since it makes the code less readable IMHO. > [...] Manlio -- 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.
Re: [go-nuts] feature request: allow literal digit underscore grouping
I asked for this a while back ("drop underscore between digits as in Ada") and the answer was no. I try to ask just once. This was shut down without much discussion at https://github.com/golang/go/issues/42. I agree that it's a nice feature. By the way, though, one nice aspect of Go is that because of how untyped constants work you can write integers using scientific notation: for i := 0; i < 10e6; i++ { // ... } This is exactly the same as if you had written 1000. (I don't think you'd want to do this in C or Java because, although it would "work", 10e6 is a floating point number and so i would be converted to a double for comparison. I am not an expert in those languages, though, so someone can correct if I'm wrong here.) On Tue, Jun 21, 2016 at 8:44 AM, Roger Packwrote: > I found recently when doing some language comparisons > > In a few other languages (ruby, java, etc.) underscores within numeric > literals to make them more readable, ex: > > 10_000_000.times do > ... > end > > go ex: > > for i := 0; i < 1000; i++ { > ... > } > > I find it helps readability, and think it would be a nice addition to the > language (or some way to group digits, perhaps there already is one?). > Consider this a feature request (go 2.0 or what not). > Cheers. > -roger- > > -- > 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.
[go-nuts] feature request: allow literal digit underscore grouping
I found recently when doing some language comparisons In a few other languages (ruby, java, etc.) underscores within numeric literals to make them more readable, ex: 10_000_000.times do ... end go ex: for i := 0; i < 1000; i++ { ... } I find it helps readability, and think it would be a nice addition to the language (or some way to group digits, perhaps there already is one?). Consider this a feature request (go 2.0 or what not). Cheers. -roger- -- 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.