[go-nuts] Re: Go could really use a while statement

2018-05-01 Thread Louki Sumirniy
I have a preferred methtod for emulating do-while: notdone:=true for notdone { if { notdone = false } } I prefer to use a negative name because I don't see why I should use a unary operator when I can just use the word NOT and not incur any runtime cost. or for ! { } The for i

[go-nuts] Re: Go could really use a while statement

2018-05-03 Thread prades . marq
Can anybody point me to a single discussion on golang-nuts that led to a significant syntax change? These threads are akin to bike shedding thus a waste of time. Adding while provide nothing of value in a language that supports basic looping. And for those who compare if and switch arguing it

[go-nuts] Re: Go could really use a while statement

2018-05-03 Thread matthewjuran
> > These threads are akin to bike shedding thus a waste of time. In storytelling relief is part of good tragedy. I consider the overloading of for to be a plus because for, while, do-while are just loops with conditions. Maybe ‘loop’ is a more Go-like keyword. loop i, e := range c { Matt O

[go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Jamie Clarkson
I agree with the first part, but not the second - 'for' is far more 'Go like' in terms of clarity and meaning Compare the first few meanings of 'loop': http://www.dictionary.com/browse/loop?s=t with 'for': http://www.dictionary.com/browse/for?s=t Although I think 'desirous' would be an excelle

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread Marc
I'm still not convinced this topic is not some kind of elaborate joke. On Tuesday, May 1, 2018 at 1:11:04 PM UTC+2, Hugh Fisher wrote: > > > Another observation from this novice Go programmer: I'm puzzled why > there's no while statement. > > I know it's possible to use a for, but it doesn't feel

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread Hugh Fisher
On Thursday, May 10, 2018 at 4:20:41 AM UTC+10, Marc wrote: > > I'm still not convinced this topic is not some kind of elaborate joke. > It's certainly diverged from my original post, which is why I'm staying quiet. cheers, Hugh Fisher -- You received this message because you are subscribe

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread matthewjuran
I’m not sure if C has been directly mentioned. I started with C so iteration is just a nice shortcut to me. Assuming you’ve always had collection iteration available an explanation is the for loop can make the useful pattern of indexing into an array up to the length of the array using an index

[go-nuts] Re: Go could really use a while statement

2018-05-09 Thread Scott Pakin
On Wednesday, May 9, 2018 at 4:59:35 PM UTC-6, matthe...@gmail.com wrote: > > I’m not sure if C has been directly mentioned. I started with C so > iteration is just a nice shortcut to me. Assuming you’ve always had > collection iteration available an explanation is the for loop can make the > us

[go-nuts] Re: Go could really use a while statement

2018-05-10 Thread matthewjuran
The lack of citations makes the content untrustworthy to me, but this English Wikipedia article on loops claims some history starting with the do loop in FORTRAN (1957): https://en.wikipedia.org/wiki/For_loop This article says the three part for loop was introduced in C/C++ (1972), and containe

[go-nuts] Re: Go could really use a while statement

2018-05-12 Thread matthewjuran
> > It's certainly diverged from my original post, which is why I'm staying > quiet. I was hoping to get back on track after you sent this so you’d want to participate. goto is another way to do loops in Go: https://play.golang.org/p/0chmb5DeOym Matt On Wednesday, May 9, 2018 at 4:26:44 PM

[go-nuts] Re: Go could really use a while statement

2018-05-13 Thread Hugh Fisher
On Sunday, May 13, 2018 at 1:20:16 AM UTC+10, matthe...@gmail.com wrote: > > It's certainly diverged from my original post, which is why I'm staying >> quiet. > > > I was hoping to get back on track after you sent this so you’d want to > participate. > I still think a while { ... } loop would

[go-nuts] Re: Go could really use a while statement

2018-05-13 Thread Louki Sumirniy
I don't understand why you are saying this after how many times so many people have pointed out that while Condition() { ... } is expressed as for Condition() { ... } The for statement with a single clause IS a while loop. You can make it explicit by putting semicolons on each side of the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-01 Thread Michael Jones
The 'do' in this could be a 'for' if for allowed an optional 'while' after the close brace. On Tue, May 1, 2018 at 9:08 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > I have a preferred methtod for emulating do-while: > > notdone:=true > for notdone { > > if { > notdone

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Lucio
E.J. Dijkstra in "A Discipline of Programming" proposed multicase "do" and "if" constructs; the former looping, the latter single-shot. The "guards" he proposed were strictly boolean expressions determining which, if any, of the guarded statements would be executed. If no guard proved true, the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Louki Sumirniy
It could be effectively added in Go by allowing an optional condition after break statements. -- 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+unsubsc

Re: [go-nuts] Re: Go could really use a while statement

2018-05-02 Thread Bakul Shah
On Wed, 02 May 2018 03:04:38 -0700 Lucio wrote: > > E.J. Dijkstra in "A Discipline of Programming" proposed multicase "do" and > "if" constructs; the former looping, the latter single-shot. The "guards" > he proposed were strictly boolean expressions determining which, if any, of > the guarded

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Jesper Louis Andersen
The reason is simply that good syntax is a really hard problem which incorporates both tech and people. In principle, you can get away with very few things in a language before it is turing complete. It is enough to have eg 'WHILE do ' where stmts can form a block of statements. Or just have recu

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread roger peppe
On 3 May 2018 at 14:46, wrote: > Can anybody point me to a single discussion on golang-nuts that led to a > significant syntax change? These threads are akin to bike shedding thus a > waste of time. I can think of a couple, although I haven't got the time to delve for links. The map key deletion

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread roger peppe
> do { ... } while is the only construct I some times miss, but then > again, it occurs fairly rarely in my code, so for now I'm rather happy to > just rewrite it in another style. When I programmed in C, I found it pretty rare to use do...while. These days I think of it more as a special case

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread 'Axel Wagner' via golang-nuts
On Thu, May 3, 2018 at 3:46 PM wrote: > And for those who compare if and switch arguing it is equivalent, you > can't do type switches with an if statement. > Yes, you can if r, ok := r.(*bytes.Buffer); ok { // Use r as a *bytes.Buffer } else if r, ok := r.(*os.File); ok { // Use r as a

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Bakul Shah
Perhaps you mean “the functional side has done away with loops” or “made do with recursion”? I still remember that as a newbie I was confused about while loops but not recursion. I thought that the while was being *continuously* monitored during the entire execution of the while and not just

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Steven Blenkinsop
loop could be used as syntax for Roger Peppe's loop: loop if x = next(); x != nil { ... } I guess you could also call that for if, but that makes me think of for if me, ok := i().(OscarMayerWeiner); ok { for _, person := range everyone { love[person] = me } } On T

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Lucio
I never felt the need to join an APL fan club, but you sure tempt me, Bakul! Is there one, or do we need to start one? What would be the minimal entry qualification? APL is the only language I learnt that to this day feels like it shifted my mindset much more than one notch. I didn't pay much a

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Michael Jones
J is the beautiful result of the APL road. On Thu, May 3, 2018 at 8:47 PM Lucio wrote: > I never felt the need to join an APL fan club, but you sure tempt me, > Bakul! > > Is there one, or do we need to start one? What would be the minimal entry > qualification? > > APL is the only language I le

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Louki Sumirniy
urgh. Wile I think the C shorthand if/then notation is kinda cool, I really think you can easily go too far with programming where all the time you save on keystrokes you pay by using the shift key a lot more and having to really carefully read. Maybe after a time it would be cool but I prefer m

Re: [go-nuts] Re: Go could really use a while statement

2018-05-03 Thread Bakul Shah
On Thu, 03 May 2018 20:46:59 -0700 Lucio wrote: > > I never felt the need to join an APL fan club, but you sure tempt me, Bakul! > > Is there one, or do we need to start one? What would be the minimal entry > qualification? There are some mailing lists and websites that you can check out (if y

Re: [go-nuts] Re: Go could really use a while statement

2018-05-07 Thread Rob Pike
The original suggestion (using while instead of for) may be the first time someone has complained that Go is not verbose enough. -rob -- 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 i

Re: [go-nuts] Re: Go could really use a while statement

2018-05-09 Thread Michael Jones
I was serious this time and the first time (years ago now) that this came up. My motivation was not really core to the Go manifesto; in addition to all the good Go usage model things, I also like using it to teach or show algorithms. In this use I wanted to be able to naturally present both: while

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Michael Jones
Maybe the central issue here has been lost because of the confusion between English words and the keywords of various languages. Let's be explicit: *a controlled looping construct may test the control condition before or after the iterated body of code. Go's 'for' tests before and and Go does not p

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Rob Pike
There is a widespread dislike of do-while in C. Pretty much every time I've wanted it, my code reviewer made me take it out. I agree it has its place but it's one of those style things that social pressures seem to force. I would not be the one to try to argue for its return; I couldn't handle the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Michael Jones
So sorry to learn of your mistreatment. I've never been struggled in an anti-do-while cultural revolution, though I can imagine the lasting emotional harm. I always* thought that C's "do {stuff} while (cond);" was a victim of syntax. The cond is far away and hidden from the do. An idea from the Go

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Michael Jones
*always as in, from learn on 6th edition at BTL in 1977. On Thu, May 10, 2018 at 3:29 PM Michael Jones wrote: > So sorry to learn of your mistreatment. I've never been struggled in an > anti-do-while cultural revolution, though I can imagine the lasting > emotional harm. > > I always* thought th

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Devon H. O'Dell
Interesting. I've never had that experience in the past 15ish years doing POSIXish systems stuff. I've always found it the more natural expression for handling EINTR from syscalls like read/write. I've also never seen anyone seriously discourage its use in ##c on freenode over the same-ish timefram

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Bakul Shah
On Thu, 10 May 2018 15:02:39 - Michael Jones wrote: > > Maybe the central issue here has been lost because of the confusion between > English words and the keywords of various languages. Let's be explicit: *a > controlled looping construct may test the control condition before or after > the

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Louki Sumirniy
I think better to use the context of the english language for a pre-condition checked after: until Condition() { ... } Or maybe just exactly mimics for, but does not test until after one run of the enclosed block: until Init(); Condition(); PostAssignment() { ... } On Friday, 11 May 2018 01:

Re: [go-nuts] Re: Go could really use a while statement

2018-05-10 Thread Dan Kortschak
Until implies a negation. The presence of unless in perl is a horror resulting from the same semantics - I'm sure it seemed like a good idea at the time. On Thu, 2018-05-10 at 23:25 -0700, Louki Sumirniy wrote: > I think better to use the context of the english language for a  > pre-condition chec

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Louki Sumirniy
Until condition is true is not a negation or negative. But placing it before the block implies pretesting as well. But adding a post-condition to the block structure is a big change to the grammar tree structure as well, just for one case, and really run-once before testing is not the most comm

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Louki Sumirniy
On that note, I think that most of the ways that gofmt changes things is nice but I think I'm disabling its use from now on because more than a few times I have seen my line count expanded massively when most of the statement blocks were just one statement. I appreciate the simplification it ma

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Jan Mercl
On Fri, May 11, 2018 at 10:22 AM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > On that note, I think that most of the ways that gofmt changes things is nice but I think I'm disabling its use from now on because more than a few times I have seen my line count expanded massively > when

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Louki Sumirniy
I strongly dispute whether forcing a single statement in a block to be on a new line benefits readability. Sure, if the statement makes the line over 80 characters, but otherwise, the contrary. More work for the index finger and more time to lose context while reading the code. I would say that

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Jan Mercl
On Fri, May 11, 2018 at 12:28 PM Louki Sumirniy < louki.sumirniy.stal...@gmail.com> wrote: > I strongly dispute whether forcing a single statement in a block to be on a new line benefits readability. Fun fact: The major point of gofmt is to bring endless and pointless code formatting disputes to

Re: [go-nuts] Re: Go could really use a while statement

2018-05-11 Thread Dan Kortschak
while dirty() { wash() } until !dirty() { wash() } Normal English semantics hold until as a negation of while. On Fri, 2018-05-11 at 01:17 -0700, Louki Sumirniy wrote: > Until condition is true is not a negation or negative. -- You received this message because you are subscrib

Re: [go-nuts] Re: Go could really use a while statement

2018-05-12 Thread Michael Jones
I bet Rob wishes he'd done that after the code reviewer's objections. On Sat, May 12, 2018 at 8:20 AM wrote: > It's certainly diverged from my original post, which is why I'm staying >> quiet. > > > I was hoping to get back on track after you sent this so you’d want to > participate. > > goto is

Re: [go-nuts] Re: Go could really use a while statement

2018-05-12 Thread matthewjuran
That would be funny to me. I have been guilty of being disrespectful to people in person about their C code choices, but I thought it was justified because I was hoping to get good technical reasons in response and didn’t intend anything personally targeted. ‘Crusade’ was a word I’d use for wha