[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 condition expression but 
it's not necessary.

The only thing you can't do without an if statement at the end of a for 
statement block is exactly

  do { ... } while Condition()

style 'run once before condition check.

Which has to be done this way:

  for {
...
if Condition() {
  break
}
  }

and for { ... } is equivalent to while true { ... } infinite loop (notice 
how it's shorter?)

On Sunday, 13 May 2018 11:34:10 UTC+3, Hugh Fisher wrote:
>
>
>
> 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 be a worthwhile 
> addition, for the reasons I've already given.
>
> However I don't see the need for an "at least once" do { ... } while 
>  loop, and even less need for more exotic loop constructs. So I 
> really don't have anything more to add. Thanks for replying to my original 
> post.
>
> cheers,
> Hugh Fisher
>  
>

-- 
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] 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 be a worthwhile 
addition, for the reasons I've already given.

However I don't see the need for an "at least once" do { ... } while 
 loop, and even less need for more exotic loop constructs. So I 
really don't have anything more to add. Thanks for replying to my original 
post.

cheers,
Hugh Fisher
 

-- 
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] 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 what I cared about. Now I don’t 
think disrespect in service of collaboration is the right approach. I hope 
that backlash Rob mentioned doesn’t exist anymore.

Matt

On Saturday, May 12, 2018 at 1:44:33 PM UTC-5, Michael Jones wrote:
>
> 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 another way to do loops in Go: 
>> https://play.golang.org/p/0chmb5DeOym
>>
>> Matt
>>
>> On Wednesday, May 9, 2018 at 4:26:44 PM UTC-5, Hugh Fisher wrote:
>>>
>>>
>>>
>>> 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 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 .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Michael T. Jones
> michae...@gmail.com 
>

-- 
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] 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 another way to do loops in Go:
> https://play.golang.org/p/0chmb5DeOym
>
> Matt
>
> On Wednesday, May 9, 2018 at 4:26:44 PM UTC-5, Hugh Fisher wrote:
>>
>>
>>
>> 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 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.
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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 UTC-5, Hugh Fisher wrote:
>
>
>
> 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 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] 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 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] 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 the end.

Anyway, no one was asking you to use gofmt. I was just pointing out, that
others may chose to ignore code that is non gofmt'ed. If I see such code in
a public repository and it's not a mistake/omission, I consider the code
not worth my attention. Nothing else happens.

-- 

-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] 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 in fact changing gofmt to force carriage returns between 
one statement and the enclosing brackets would not bother anyone, but I 
doubt it's ever going to happen.

I like the way it lays out lists of variables in structs and const blocks, 
but then golint coerces you to put comments above exported variables and 
then gofmt breaks the vertical alignment anyway, so I'd rather lay them out 
with nice verticals just like it would be without those godoc comments.

I write my code so that it is very readable, and I don't mind having to 
manually do some of this work since gofmt ignores the convention from 
nearly every other language allowing a single statement to be semantically 
the same as a statement block on a flow control statement. Visual Studio 
Code makes it very easy to manually line things up this way anyway so, read 
my code or not, idc, it won't be as spread out as gofmt.

On Friday, 11 May 2018 11:26:13 UTC+3, Jan Mercl wrote:
>
> On Fri, May 11, 2018 at 10:22 AM Louki Sumirniy  > 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 most of the statement blocks were just one statement. I appreciate 
> the simplification it makes to the compiler to enforce all statement blocks 
> regardless of how many statements inside are 
> > wrapped, but I don't think it makes sense to add two lines just to do 
> something as simple as a break statement.
>
> Everyone is free to not use gofmt. Everyone else is free to not read code 
> that's not gofmt'ed.
>
> -- 
>
> -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] 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 most of the statement blocks were just one statement. I appreciate
the simplification it makes to the compiler to enforce all statement blocks
regardless of how many statements inside are
> wrapped, but I don't think it makes sense to add two lines just to do
something as simple as a break statement.

Everyone is free to not use gofmt. Everyone else is free to not read code
that's not gofmt'ed.

-- 

-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] 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 makes to the compiler to enforce all statement blocks regardless of how 
many statements inside are wrapped, but I don't think it makes sense to add 
two lines just to do something as simple as a break statement.

On Friday, 11 May 2018 11:17:14 UTC+3, Louki Sumirniy wrote:
>
> 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 
> common type of iteration done anyway. 
>
> Any which way it is implemented amounts to the same as having a boolean 
> flag declared as true prior to the loop, and flipping it after. 
>
> If there was a more concise conditional break you wouldn't even care there 
> wasn't a post test, such as this:
>
> for {
>   statements()
>   break if condition()
> }
>
> instead of this:
>
> for {
>   statements()
>   if condition() {
> break
>   }
> }
>
> but you could just turn off automatic beautification and do this:
>
> for {
>   statements()
>   if condition() { break }
> }
>  
> On Friday, 11 May 2018 09:44:03 UTC+3, kortschak wrote:
>>
>> 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 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() { ... } 
>>
>

-- 
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] 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 
common type of iteration done anyway. 

Any which way it is implemented amounts to the same as having a boolean 
flag declared as true prior to the loop, and flipping it after. 

If there was a more concise conditional break you wouldn't even care there 
wasn't a post test, such as this:

for {
  statements()
  break if condition()
}

instead of this:

for {
  statements()
  if condition() {
break
  }
}

but you could just turn off automatic beautification and do this:

for {
  statements()
  if condition() { break }
}
 
On Friday, 11 May 2018 09:44:03 UTC+3, kortschak wrote:
>
> 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 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() { ... } 
>

-- 
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] Re: Go could really use a while statement

2018-05-11 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 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() { ... }

-- 
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] Re: Go could really use a while statement

2018-05-11 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:29:55 UTC+3, 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 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 
> line of reasoning could be like this:
>
> for preCondition; beforeCond; updateStatement; afterCond {stuff}
>
> The argument for this would be just one looping construct, capable of a 
> pre and post conditions, all set out at the start. It might be pretty 
> enough to escape the thuggery of the past. ;-)
>
> Michael
>
> On Thu, May 10, 2018 at 1:32 PM Rob Pike  
> wrote:
>
>> 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 backlash.
>>
>> -rbo
>>
>>
>
> -- 
> Michael T. Jones
> michae...@gmail.com 
>

-- 
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] 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 timeframe. I think the only place I may have seen it come
up may have been if someone was doing something egregious with a
macro. You've of course worked on C with far more people for far
longer than I have, but I'm really surprised to hear that this is a
widespread thing, and would be curious to hear more about where that
came from. Do C++ folks hate it and try to force that on C, perhaps?

--dho

2018-05-10 13:32 GMT-07:00 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
> backlash.
>
> -rbo
>
> --
> 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] 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 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
> line of reasoning could be like this:
>
> for preCondition; beforeCond; updateStatement; afterCond {stuff}
>
> The argument for this would be just one looping construct, capable of a
> pre and post conditions, all set out at the start. It might be pretty
> enough to escape the thuggery of the past. ;-)
>
> Michael
>
> On Thu, May 10, 2018 at 1:32 PM Rob Pike  wrote:
>
>> 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 backlash.
>>
>> -rbo
>>
>>
>
> --
> Michael T. Jones
> michael.jo...@gmail.com
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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
line of reasoning could be like this:

for preCondition; beforeCond; updateStatement; afterCond {stuff}

The argument for this would be just one looping construct, capable of a pre
and post conditions, all set out at the start. It might be pretty enough to
escape the thuggery of the past. ;-)

Michael

On Thu, May 10, 2018 at 1:32 PM Rob Pike  wrote:

> 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 backlash.
>
> -rbo
>
>

-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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
backlash.

-rbo

-- 
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] 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
provide keyword means to specify the test happen after.*

Not a crisis, everyone works around this, but, the workaround is a
workaround. Language shapes thought. Languages that express test-after in
their vocabulary embrace code and data structuring that depend on it.
People who know such languages (such as C and others) will miss it. In 800
AD Charlemagne said, "To have a second language is to have a second soul."
Same for computer languages.



On Thu, May 10, 2018 at 7:17 AM  wrote:

> 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 container iteration was introduced in Maple (1980).
>
> for e in c while w do
> # loop body
> od;
>
> The people writing these articles claim “Do while”, “While”, “For”,
> “Foreach”, and “Infinite” are loop constructs. All of these are done by for
> in Go.
>
> Another observation from this novice Go programmer: I'm puzzled why
>> there's no while statement.
>
>
> I think “it was an arbitrary choice based on experience” might be the
> answer but I don’t know. I like having the one keyword.
>
> Matt
>
> On Tuesday, May 1, 2018 at 6:11:04 AM UTC-5, 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 right to me. I
>> always
>> think of for loops as for iterating over data structures. Originally just
>> arrays, but languages like Python and Objective-C have extended for
>> loops to other collections as well. "Looping until some condition is met"
>> for me is a different control structure and needs a different keyword.
>>
>> There'd be overlap with the for statement, but if-then-else and switch
>> with boolean case overlap too.
>>
>> And since while has been a reserved keyword in a lot of programming
>> languages for many decades, I would bet a reasonable amount of
>> money that a while statement could be added to Go right now and not
>> break anyone's production code.
>>
>> cheers,
>> Hugh Fisher
>>
>> --
> 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.
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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 container iteration was introduced in Maple (1980).

for e in c while w do
# loop body
od;

The people writing these articles claim “Do while”, “While”, “For”, 
“Foreach”, and “Infinite” are loop constructs. All of these are done by for 
in Go.

Another observation from this novice Go programmer: I'm puzzled why there's 
> no while statement.


I think “it was an arbitrary choice based on experience” might be the 
answer but I don’t know. I like having the one keyword.

Matt

On Tuesday, May 1, 2018 at 6:11:04 AM UTC-5, 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 right to me. I 
> always
> think of for loops as for iterating over data structures. Originally just
> arrays, but languages like Python and Objective-C have extended for
> loops to other collections as well. "Looping until some condition is met"
> for me is a different control structure and needs a different keyword.
>
> There'd be overlap with the for statement, but if-then-else and switch
> with boolean case overlap too.
>
> And since while has been a reserved keyword in a lot of programming
> languages for many decades, I would bet a reasonable amount of
> money that a while statement could be added to Go right now and not
> break anyone's production code.
>
> cheers,
> Hugh Fisher
>
>

-- 
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] 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 
> useful pattern of indexing into an array up to the length of the array 
> using an index variable.
>
> s := [5]int{0, 1, 2, 3, 4}
> // this C-style iteration prints 12345
> for i := 0; i < len(s); i++ {
> fmt.Print(s[i]+1)
> }
>
> …except that in Go one would more naturally write

for _, e := range s {
fmt.Print(e + 1)
}

— Scott 

-- 
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] 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 (condition) do {stuff} // aka, for

and

do {stuff} while (condition)

It comes up in function approximation, linked list traversal, and many
computer science situations. As has been pointed out, it is clear how to
achieve the second with the first using tests in side an infinite loop. I
do it enough that it is "natural" to work around the issue. That does not
make the code natural though. It is a workaround and that's what appears in
the text. I don't like that so I use go-like pseudocode.

That's ok. I still love Go for what it is good at.

Michael

On Wed, May 9, 2018 at 3:59 PM  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
> useful pattern of indexing into an array up to the length of the array
> using an index variable.
>
> s := [5]int{0, 1, 2, 3, 4}
> // this C-style iteration prints 12345
> for i := 0; i < len(s); i++ {
> fmt.Print(s[i]+1)
> }
>
> Coming from C it makes sense to me to combine all looping, including
> collection iteration, into one keyword. For, while, and do-while all look
> the same to me.
>
> Matt
>
> On Wednesday, May 9, 2018 at 4:26:44 PM UTC-5, Hugh Fisher wrote:
>>
>>
>>
>> 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 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.
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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 variable.

s := [5]int{0, 1, 2, 3, 4}
// this C-style iteration prints 12345
for i := 0; i < len(s); i++ {
fmt.Print(s[i]+1)
}

Coming from C it makes sense to me to combine all looping, including 
collection iteration, into one keyword. For, while, and do-while all look 
the same to me.

Matt

On Wednesday, May 9, 2018 at 4:26:44 PM UTC-5, Hugh Fisher wrote:
>
>
>
> 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 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] 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 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] 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 right to me. I 
> always
> think of for loops as for iterating over data structures. Originally just
> arrays, but languages like Python and Objective-C have extended for
> loops to other collections as well. "Looping until some condition is met"
> for me is a different control structure and needs a different keyword.
>
> There'd be overlap with the for statement, but if-then-else and switch
> with boolean case overlap too.
>
> And since while has been a reserved keyword in a lot of programming
> languages for many decades, I would bet a reasonable amount of
> money that a while statement could be added to Go right now and not
> break anyone's production code.
>
> cheers,
> Hugh Fisher
>
>

-- 
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] Re: Go could really use a while statement

2018-05-08 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 it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 you are interested I can send you some links off
list). In particular see http://www.jsoftware.com/papers/50/
and other stuff at www.jsoftware.com

What I was wishing for here is not to push APL but to see Go
become more of a multi-paradigm language. Not unlike numpy in
Python but type safe. It won't allow writing code as beautiful
and mysterious as an APL one liner but would be quite userful.

-- 
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] 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 my 
code to be nearly understandable by a non-programmer if they sound it out 
like a child learning phonetics.

On Friday, 4 May 2018 07:37:27 UTC+3, Michael Jones wrote:
>
> 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 learnt that to this day feels like it shifted 
>> my mindset much more than one notch. I didn't pay much attention to the 
>> functional languages, though, my university lecturers seem to feel the 
>> students either bought into them or didn't, they weren't going to push 
>> them. I never quite made recursion my own, I almost always resorted to 
>> translating it into stack-driven iteration. To this day.
>>
>> In passing, I studied at an institution where I had to arrange for the 
>> APL interpreter to be installed (I was a little privileged, so I was 
>> allowed to do it myself) and interactive computing became more prevalent 
>> while I was there. APL wasn't a Computer Science subject, I became the only 
>> user of a poorly supported, if valiant, interpreter.
>>
>> Lucio.
>>
>> -- 
>> 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 .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Michael T. Jones
> michae...@gmail.com 
>

-- 
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] 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 learnt that to this day feels like it shifted
> my mindset much more than one notch. I didn't pay much attention to the
> functional languages, though, my university lecturers seem to feel the
> students either bought into them or didn't, they weren't going to push
> them. I never quite made recursion my own, I almost always resorted to
> translating it into stack-driven iteration. To this day.
>
> In passing, I studied at an institution where I had to arrange for the APL
> interpreter to be installed (I was a little privileged, so I was allowed to
> do it myself) and interactive computing became more prevalent while I was
> there. APL wasn't a Computer Science subject, I became the only user of a
> poorly supported, if valiant, interpreter.
>
> Lucio.
>
> --
> 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.
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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 attention to the 
functional languages, though, my university lecturers seem to feel the 
students either bought into them or didn't, they weren't going to push 
them. I never quite made recursion my own, I almost always resorted to 
translating it into stack-driven iteration. To this day.

In passing, I studied at an institution where I had to arrange for the APL 
interpreter to be installed (I was a little privileged, so I was allowed to 
do it myself) and interactive computing became more prevalent while I was 
there. APL wasn't a Computer Science subject, I became the only user of a 
poorly supported, if valiant, interpreter.

Lucio.

-- 
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] 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 Thu, May 3, 2018 at 3:56 PM  wrote:

> 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
>
> On Thursday, May 3, 2018 at 8:46:36 AM UTC-5, M P r a d e s 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.
>>
>> Adding while provide nothing of value in a language that supports basic
>> looping. And for those who compare if and switch arguing it is equivalent,
>> you can't do type switches with an if statement.
>>
>> This is discussion is going nowhere.
>>
> --
> 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] 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 excellent new keyword:

desirous of: a longing for something

desirous  {
}

Jamie

 On Thursday, May 3, 2018 at 8:56:35 PM UTC+1, matthe...@gmail.com wrote:
>
> 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
>
> On Thursday, May 3, 2018 at 8:46:36 AM UTC-5, M P r a d e s 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. 
>>
>> Adding while provide nothing of value in a language that supports basic 
>> looping. And for those who compare if and switch arguing it is equivalent, 
>> you can't do type switches with an if statement.
>>
>> This is discussion is going nowhere.
>>
>

-- 
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] 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

On Thursday, May 3, 2018 at 8:46:36 AM UTC-5, M P r a d e s 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. 
>
> Adding while provide nothing of value in a language that supports basic 
> looping. And for those who compare if and switch arguing it is equivalent, 
> you can't do type switches with an if statement.
>
> This is discussion is going nowhere.
>

-- 
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] 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 at the 
*start* of the loop! Until I saw it explained in terms of recursion. Recursion 
is just redoing. Why didn’t they just use *it* instead of adding a confusing 
construct? They gave loops and never got around to giving us TCO!

Even now I find it a bit surprising that many languages allow you to construct 
collections of data items all at once but don’t provide useful operations on 
entire collections - you have deal with each item one at a time. Operations 
such as map, scan, filter, reduce, iterate, group, sort, cross and dot products 
etc, if built in the language, provide many opportunities for optimization & 
using concurrency, and you don’t have to worry about getting boundary 
conditions wrong or off by one errors. These operations compose well and are 
quite compact (which may make the initial learning steeper but later become 
very useful). Prof. Alan Perlis wrote a couple of essays relevant to this which 
I find inspiring:

In Praise of APL: A Language for Lyrical Programming 
http://www.jsoftware.com/papers/perlis77.htm

Every time I read this essay I discover something new! Just now I wrote and 
deleted “The structured programming movement of 60s and 70s has a lot to answer 
for!” in the context of loops and no TCO. Compared my flippant remark he makes 
the same case more persuasively. He argues that structured programming is less 
relevant if you can express your algorithm in a few lines instead of a few 
pages. Implicitly, a language should make it easy to express algorithms this 
way. He praises APL but I think we can read it as a praise of a certain style 
of programming.

Also:
APL is more French than English
http://www.jsoftware.com/papers/perlis78.htm

I am less concerned about surface syntax issues such as a lack of a while 
statement, when the fact is, Go is not very good at providing features to build 
the above kind of functions easily or efficiently.


> On May 3, 2018, at 8:06 AM, Jesper Louis Andersen 
>  wrote:
> 
> In practice, convenience has it that people often add additional syntax, 
> albeit it seems to me that imperative languages generally have opted on the 
> side of having multiple loop constructs, whereas the functional side has done 
> away with recursion, more or less. This is mostly a stylistic argument as 
> things blend in the end: most modern compilers use SSA, which can be seen as 
> a variant of implementing all loops as recursion. And vice versa, recursion 
> is often implemented via tail call optimization: which implements a loop as a 
> goto. It is just dependent on the glasses you wear, really.

-- 
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] 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 an *os.File
} else {
// Default case
}


>
> This is discussion is going nowhere.
>
> --
> 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] 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 of:

 for {
  statements1
  if cond {
  break
  }
  statements2
  }

where either statements1 and statements2 may be empty. I find it
almost as common to have both non-empty (not representable with
do...while) as to have statements2 empty and statements1 present.

I like the way things are tbh.


On 3 May 2018 at 16:06, Jesper Louis Andersen
 wrote:
> 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 recursion, in which case
> you need no looping construct at all.
>
> In practice, convenience has it that people often add additional syntax,
> albeit it seems to me that imperative languages generally have opted on the
> side of having multiple loop constructs, whereas the functional side has
> done away with recursion, more or less. This is mostly a stylistic argument
> as things blend in the end: most modern compilers use SSA, which can be seen
> as a variant of implementing all loops as recursion. And vice versa,
> recursion is often implemented via tail call optimization: which implements
> a loop as a goto. It is just dependent on the glasses you wear, really.
>
> What is really going on is that you strike a delicate balance by adding more
> syntax:
>
> * Is the new construct going to be able to convey information (Ian's
> if/switch example - they are often used differently, which makes the reader
> know what follows).
> * Is the new construct going to add cognitive load on readers?
> * Is the new construct going to make it harder to learn the language as
> there are more information to take in?
> * Will the new construct add considerable expressive power in the form of a
> more succinct style?
> * Will it introduce a new class of common errors in programs?
> * Will the new construct interfere with existing syntactical groups in ways
> that makes the program harder to understand?
> * Will the semantics be clear? Will it take readers longer time to grasp
> what is going on?
> * Is it backwards compatible? How many code bases will it affect?
>
> People will not answer these questions the same, so a good solution must
> attempt the impossible, which is to cater to everyone's desires. This is why
> it is so hard to change syntax. It is also why one must accept a compromise:
> you can't have everything you want in a language, and you have to make
> certain sacrifices along the way. But it is still fair if people write to
> look for support for their preferences. Perhaps not in Go, but then another
> language might cater to you more and also pick up the suggestions.
>
> 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.
>
> On Thu, May 3, 2018 at 3:46 PM  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.
>>
>> Adding while provide nothing of value in a language that supports basic
>> looping. And for those who compare if and switch arguing it is equivalent,
>> you can't do type switches with an if statement.
>>
>> This is discussion is going nowhere.
>>
>> --
>> 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] 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 syntax. The error keyword.

-- 
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] 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 recursion, in which case
you need no looping construct at all.

In practice, convenience has it that people often add additional syntax,
albeit it seems to me that imperative languages generally have opted on the
side of having multiple loop constructs, whereas the functional side has
done away with recursion, more or less. This is mostly a stylistic argument
as things blend in the end: most modern compilers use SSA, which can be
seen as a variant of implementing all loops as recursion. And vice versa,
recursion is often implemented via tail call optimization: which implements
a loop as a goto. It is just dependent on the glasses you wear, really.

What is really going on is that you strike a delicate balance by adding
more syntax:

* Is the new construct going to be able to convey information (Ian's
if/switch example - they are often used differently, which makes the reader
know what follows).
* Is the new construct going to add cognitive load on readers?
* Is the new construct going to make it harder to learn the language as
there are more information to take in?
* Will the new construct add considerable expressive power in the form of a
more succinct style?
* Will it introduce a new class of common errors in programs?
* Will the new construct interfere with existing syntactical groups in ways
that makes the program harder to understand?
* Will the semantics be clear? Will it take readers longer time to grasp
what is going on?
* Is it backwards compatible? How many code bases will it affect?

People will not answer these questions the same, so a good solution must
attempt the impossible, which is to cater to everyone's desires. This is
why it is so hard to change syntax. It is also why one must accept a
compromise: you can't have everything you want in a language, and you have
to make certain sacrifices along the way. But it is still fair if people
write to look for support for their preferences. Perhaps not in Go, but
then another language might cater to you more and also pick up the
suggestions.

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.

On Thu, May 3, 2018 at 3:46 PM  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.
>
> Adding while provide nothing of value in a language that supports basic
> looping. And for those who compare if and switch arguing it is equivalent,
> you can't do type switches with an if statement.
>
> This is discussion is going nowhere.
>
> --
> 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] 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 is equivalent, 
you can't do type switches with an if statement.

This is discussion is going nowhere.

-- 
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] 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 statements would be executed. If no guard proved true, the if 
> statement would fail (abort), the do statement would stop iterating. If 
> multiple guards proved true, one would be picked at random from the 
> succesful ones.
> 
> I was very disappointed when Go stayed with the more conservative if and 
> for, although I could not make any proposal on how to implement Dijkstra's 
> ideas in a Go-like language. It's regrettable, in my opinion; I found the 
> proposed uniformity very appealing.

In Go select plays that role. Using guarded commands to
replace switch or if would be rather expensive. Pragmatics
matter.

-- 
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] 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 if 
statement would fail (abort), the do statement would stop iterating. If 
multiple guards proved true, one would be picked at random from the 
succesful ones.

I was very disappointed when Go stayed with the more conservative if and 
for, although I could not make any proposal on how to implement Dijkstra's 
ideas in a Go-like language. It's regrettable, in my opinion; I found the 
proposed uniformity very appealing.

Lucio.

-- 
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] 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 = 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 is so awesome that the only that is theoretically missing is a
> do-while.
>
> Also, another way to do this would be using labels. If you put a label
> before the part beginning what you want to repeat, you can put a condition
> at the end that jumps to the label for your repeat condition. I think the
> label could even be Do:
>
> But it would be pretty cool if a do-while was added, since it won't break
> old code, but it will break using old versions prior to this addition. It
> would look like this
>
> do {
>
> } while 
>
> I suppose. Someone posted about a macro processor that probably could do
> something like this. I personally don't see the point because most of the
> time I can find a way to use the second construct I showed earlier - a
> condition that does not evaluate false until the inner block has executed
> at least once.
>
> On Tuesday, 1 May 2018 14:11:04 UTC+3, 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 right to me. I
>> always
>> think of for loops as for iterating over data structures. Originally just
>> arrays, but languages like Python and Objective-C have extended for
>> loops to other collections as well. "Looping until some condition is met"
>> for me is a different control structure and needs a different keyword.
>>
>> There'd be overlap with the for statement, but if-then-else and switch
>> with boolean case overlap too.
>>
>> And since while has been a reserved keyword in a lot of programming
>> languages for many decades, I would bet a reasonable amount of
>> money that a while statement could be added to Go right now and not
>> break anyone's production code.
>>
>> cheers,
>> Hugh Fisher
>>
>> --
> 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.
>


-- 
Michael T. Jones
michael.jo...@gmail.com

-- 
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] 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 is so awesome that the only that is theoretically missing is a 
do-while. 

Also, another way to do this would be using labels. If you put a label 
before the part beginning what you want to repeat, you can put a condition 
at the end that jumps to the label for your repeat condition. I think the 
label could even be Do:

But it would be pretty cool if a do-while was added, since it won't break 
old code, but it will break using old versions prior to this addition. It 
would look like this

do {

} while 

I suppose. Someone posted about a macro processor that probably could do 
something like this. I personally don't see the point because most of the 
time I can find a way to use the second construct I showed earlier - a 
condition that does not evaluate false until the inner block has executed 
at least once.

On Tuesday, 1 May 2018 14:11:04 UTC+3, 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 right to me. I 
> always
> think of for loops as for iterating over data structures. Originally just
> arrays, but languages like Python and Objective-C have extended for
> loops to other collections as well. "Looping until some condition is met"
> for me is a different control structure and needs a different keyword.
>
> There'd be overlap with the for statement, but if-then-else and switch
> with boolean case overlap too.
>
> And since while has been a reserved keyword in a lot of programming
> languages for many decades, I would bet a reasonable amount of
> money that a while statement could be added to Go right now and not
> break anyone's production code.
>
> cheers,
> Hugh Fisher
>
>

-- 
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.