Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-03 Thread Marcin Romaszewicz
Indeed!

Go has while loops :)

for {
  // do some stuff
  if !condition { break }
}

instead of
{
  // do some stuff
} while condition

They are identical functionally, so why bother with the second syntax? You
then get into arguments about which one to use.

-- Marcin

On Tue, Nov 3, 2020 at 11:31 AM 'Amnon Cohen' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Languages often have a whole variety of loop constructs.
> C has for loops as well us while loops.
> Go adopts the principle from the Zen of python:
>
> *There should be one-- and preferably only one --obvious way to do it. *It
> takes a minimalist approach - there is only one looping construct: the for
> loop.
>
> This is an excellent decision, IMO.
>
>
>>>
> Red Sift is the power behind OnDMARC and OnINBOX.
>
> You can find us at 21A Noel Street, 4th Floor, London, W1F 8GR.
>
>
> Red Sift is a limited company registered in England and Wales. Registered
> number: 09240956. Registered office: Kemp House, 152 City Road, London,
> EC1V 2NX.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/8d492b26-4784-448f-9714-79c43bc93527n%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CA%2Bv29Lv6k_w7M%3DciU%2BUoPSUYGaP_rekszdaHrLN_zNcaoihebg%40mail.gmail.com.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-03 Thread 'Amnon Cohen' via golang-nuts
Languages often have a whole variety of loop constructs.
C has for loops as well us while loops.
Go adopts the principle from the Zen of python:

*There should be one-- and preferably only one --obvious way to do it. *It 
takes a minimalist approach - there is only one looping construct: the for 
loop.

This is an excellent decision, IMO.


>>
-- 


Red Sift is the power behind OnDMARC and OnINBOX.

You can find us at 21A 
Noel Street, 4th Floor, London, W1F 8GR.




Red Sift is a limited company 
registered in England and Wales. Registered number: 09240956. Registered 
office: Kemp House, 152 City Road, London, EC1V 2NX.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8d492b26-4784-448f-9714-79c43bc93527n%40googlegroups.com.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-03 Thread Jan Mercl
On Tue, Nov 3, 2020 at 6:09 AM 'Dan Kortschak' via golang-nuts
 wrote:

> My first professional programming language was Perl, decades later I
> still wake up in a sweat thinking about post-fix conditionals and the
> 'unless' conditional.

I don't miss MUMPS post conditional either.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-Wte4mDU3YJ010nLzV3KtsTBjx%3D2P2-N7gaFaVmTL1p-g%40mail.gmail.com.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread Tyler Compton
Thanks, Dan. Those seem like well-reasoned points.

On Mon, Nov 2, 2020 at 9:33 PM 'Dan Kortschak' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> There are two parts. The worse part is the negative conditional
> (unless), which has the problem that humans are bad at negations;
> nearly always when there is a complex condition with an "unless", it
> needs to be mentally refactored into an "if !" (when working through
> other people's bugs, I invariably — at least temporarily — inverted the
> condition and replaced the "unless" with an "if").
>
> The post-fix conditional syntax says a whole heap of stuff that's going
> to happen, and only when you get to the end of the line do you see that
> it might not.
>
> Putting a single positively oriented syntax, at the front of
> conditional blocks greatly simplifies the thinking about what is going
> to happen in a section of code.
>
> On Mon, 2020-11-02 at 21:22 -0800, Tyler Compton wrote:
> > I don't think I'm personally sold on this proposal either, but I'm
> > curious what bad experiences you've had with post-fix conditionals. I
> > haven't personally used a language with post-fix conditionals and it
> > sounds like that might be to my benefit :)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/81c874ec04cea0e9e8f73d251cccf01cfa9b9e19.camel%40kortschak.io
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA%3DXfu1BdVrmx9kjkxPH%3DrTvVHgFyiYN_RMH1uM7YXoj2zyXHg%40mail.gmail.com.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread 'Dan Kortschak' via golang-nuts
There are two parts. The worse part is the negative conditional
(unless), which has the problem that humans are bad at negations;
nearly always when there is a complex condition with an "unless", it
needs to be mentally refactored into an "if !" (when working through
other people's bugs, I invariably — at least temporarily — inverted the
condition and replaced the "unless" with an "if").

The post-fix conditional syntax says a whole heap of stuff that's going
to happen, and only when you get to the end of the line do you see that
it might not.

Putting a single positively oriented syntax, at the front of
conditional blocks greatly simplifies the thinking about what is going
to happen in a section of code.

On Mon, 2020-11-02 at 21:22 -0800, Tyler Compton wrote:
> I don't think I'm personally sold on this proposal either, but I'm
> curious what bad experiences you've had with post-fix conditionals. I
> haven't personally used a language with post-fix conditionals and it
> sounds like that might be to my benefit :)



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/81c874ec04cea0e9e8f73d251cccf01cfa9b9e19.camel%40kortschak.io.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread Tyler Compton
I don't think I'm personally sold on this proposal either, but I'm curious
what bad experiences you've had with post-fix conditionals. I haven't
personally used a language with post-fix conditionals and it sounds like
that might be to my benefit :)

On Mon, Nov 2, 2020 at 9:09 PM 'Dan Kortschak' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> My first professional programming language was Perl, decades later I
> still wake up in a sweat thinking about post-fix conditionals and the
> 'unless' conditional.
>
> Please no.
>
> On Mon, 2020-11-02 at 14:26 -0800, Jeffrey Paul wrote:
> > Hello Gophers,
> >
> > There's two tiny pieces of syntactic sugar I really miss from a few
> > other languages that I think would add a nice bit of ergonomics and
> > convenience to Go (which I now play as my main) without increasing
> > any magic or spooky action at a distance.
> >
> > They are:
> >
> > - postfix conditionals
> >
> > and
> >
> > - until (while!) and unless (if!) (which probably also means adding
> > `while`)
> >
> > This allows for lovely expressions such as the following examples:
> >
> >i.NotifySomeone() if j.HasExpiredItems()
> >
> >time.Sleep(1 * time.Second) until thing.IsReady()
> >
> >b.ReportActivity(e) unless u.HasOptedOut()
> >
> >q.ProcessItem() while server.Active()
> >
> >until(time.Now().After(notAfter)) {
> >   // do something while we still can
> >}
> >
> >p.processEvents() until p.shutdownRequested
> >
> > and, my favorite:
> >
> >panic("can't even") if err != nil
> >
> > There are, of course, various ways of doing some of this sort of
> > synchronization stuff in these contrived examples using
> > channels/goroutines/timers, but this sort of syntax is quite useful
> > for simple straight-line synchronous code, and, in my view, increases
> > readability without sacrificing anything.
> >
> > I know that `while` isn't a distinct thing in Go, and for
> > consistency's sake, this might necessitate adding such a construct as
> > well (if you can use it as a postfix conditional, you should probably
> > be able to use it as `while(cond) {}` too).
> >
> > What do you think?  I really miss this syntax from other
> > languages.  It's been in Perl and Ruby for ages, and, more recently,
> > CoffeeScript had it for a moment, but it didn't make it over into ES
> > with the other notable features from it.  I think it's a lovely
> > convenience without changing the operation of the language itself.
> >
> > Best,
> > -sneak
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/99896e4fcd832c0003bb5e23ffd1a72837ea49bd.camel%40kortschak.io
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA%3DXfu1RfkK%2B-4kKXUYSYiOve1Kq57ZNxAnOdGh7jbuDdUsKYA%40mail.gmail.com.


Re: [go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread 'Dan Kortschak' via golang-nuts
My first professional programming language was Perl, decades later I
still wake up in a sweat thinking about post-fix conditionals and the
'unless' conditional.

Please no.

On Mon, 2020-11-02 at 14:26 -0800, Jeffrey Paul wrote:
> Hello Gophers,
> 
> There's two tiny pieces of syntactic sugar I really miss from a few
> other languages that I think would add a nice bit of ergonomics and
> convenience to Go (which I now play as my main) without increasing
> any magic or spooky action at a distance.
> 
> They are:
> 
> - postfix conditionals
> 
> and
> 
> - until (while!) and unless (if!) (which probably also means adding
> `while`)
> 
> This allows for lovely expressions such as the following examples:
> 
>i.NotifySomeone() if j.HasExpiredItems()
> 
>time.Sleep(1 * time.Second) until thing.IsReady()
> 
>b.ReportActivity(e) unless u.HasOptedOut()
> 
>q.ProcessItem() while server.Active()
> 
>until(time.Now().After(notAfter)) {
>   // do something while we still can
>}
> 
>p.processEvents() until p.shutdownRequested
> 
> and, my favorite:
> 
>panic("can't even") if err != nil
> 
> There are, of course, various ways of doing some of this sort of
> synchronization stuff in these contrived examples using
> channels/goroutines/timers, but this sort of syntax is quite useful
> for simple straight-line synchronous code, and, in my view, increases
> readability without sacrificing anything.
> 
> I know that `while` isn't a distinct thing in Go, and for
> consistency's sake, this might necessitate adding such a construct as
> well (if you can use it as a postfix conditional, you should probably
> be able to use it as `while(cond) {}` too).
> 
> What do you think?  I really miss this syntax from other
> languages.  It's been in Perl and Ruby for ages, and, more recently,
> CoffeeScript had it for a moment, but it didn't make it over into ES
> with the other notable features from it.  I think it's a lovely
> convenience without changing the operation of the language itself.
> 
> Best,
> -sneak
> 


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/99896e4fcd832c0003bb5e23ffd1a72837ea49bd.camel%40kortschak.io.


[go-nuts] Syntactic Sugar Idea for Go 2.0: until/unless, and postfix conditionals

2020-11-02 Thread Jeffrey Paul
Hello Gophers,

There's two tiny pieces of syntactic sugar I really miss from a few other 
languages that I think would add a nice bit of ergonomics and convenience to Go 
(which I now play as my main) without increasing any magic or spooky action at 
a distance.

They are:

- postfix conditionals

and

- until (while!) and unless (if!) (which probably also means adding `while`)

This allows for lovely expressions such as the following examples:

   i.NotifySomeone() if j.HasExpiredItems()

   time.Sleep(1 * time.Second) until thing.IsReady()

   b.ReportActivity(e) unless u.HasOptedOut()

   q.ProcessItem() while server.Active()

   until(time.Now().After(notAfter)) {
// do something while we still can
   }

   p.processEvents() until p.shutdownRequested

and, my favorite:

   panic("can't even") if err != nil

There are, of course, various ways of doing some of this sort of 
synchronization stuff in these contrived examples using 
channels/goroutines/timers, but this sort of syntax is quite useful for simple 
straight-line synchronous code, and, in my view, increases readability without 
sacrificing anything.

I know that `while` isn't a distinct thing in Go, and for consistency's sake, 
this might necessitate adding such a construct as well (if you can use it as a 
postfix conditional, you should probably be able to use it as `while(cond) {}` 
too).

What do you think?  I really miss this syntax from other languages.  It's been 
in Perl and Ruby for ages, and, more recently, CoffeeScript had it for a 
moment, but it didn't make it over into ES with the other notable features from 
it.  I think it's a lovely convenience without changing the operation of the 
language itself.

Best,
-sneak

-- 
Jeffrey Paul - sneak@sneak.berlin
+1 312 361 0355 (voice, sms, Signal)
5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/D50EAFC9-4662-429B-AF4E-9C0612F86D66%40sneak.berlin.