Re: [go-nuts] `on err` alternative to `try()` has traction...?

2019-07-09 Thread Liam Breck
The controversy between try and explicit error checking is why I wrote this
proposal, to provide a compromise that's both explicit and terse.

On Fri, Jul 5, 2019, 11:08 PM Liam Breck  wrote:

> I've expanded the proposal to address feedback from the Go team. It now
> offers a more special purpose construct than the generic if-variant 'on'.
>
> See the Critiques section in
> https://github.com/golang/go/issues/32611
>
>
> On Tue, Jul 2, 2019, 12:57 PM Liam  wrote:
>
>> This proposal has attracted modest attention from the Go team...
>> https://github.com/golang/go/issues/32611
>>
>> It suggests:
>>
>> err := f()
>> on err, 
>>
>> on err, return err// any type can be tested for non-zero
>> on err, return fmt.Errorf(...)
>>
>> on err, fmt.Println(err)  // doesn't stop the function
>> on err, continue  // retry in a loop
>>
>> on err, goto label// labeled handler invocation
>> on err, hname // named handler invocation
>>
>>
>>
>> And offers these possible extensions:
>>
>> on err, os.IsNotExist(err):  
>> on err, err == io.EOF:   
>> on err, err.(*os.PathError): // doesn't panic if not a match
>>
>> on err, : 
>> on err:   // this pair provides if/else in 2 lines
>>
>> on err := f(),  // for assignment with single lvalue
>>
>>
>>
>> Other punctuation is possible, e.g. on (err) 
>>
>> Now if we could just convince the Go gods to prototype this along with
>> try() in 1.14 :-)
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/golang-nuts/4Djft8snCjM/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/1b7ab9bd-0c1b-4658-8ee2-a36544b58f20%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKvHMgQpFe-tOuDyYfVE%3DzfLUjZgk5nq%3D5Hdh8wXE_v3cmq75Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] `on err` alternative to `try()` has traction...?

2019-07-05 Thread Liam Breck
I've expanded the proposal to address feedback from the Go team. It now
offers a more special purpose construct than the generic if-variant 'on'.

See the Critiques section in
https://github.com/golang/go/issues/32611


On Tue, Jul 2, 2019, 12:57 PM Liam  wrote:

> This proposal has attracted modest attention from the Go team...
> https://github.com/golang/go/issues/32611
>
> It suggests:
>
> err := f()
> on err, 
>
> on err, return err// any type can be tested for non-zero
> on err, return fmt.Errorf(...)
>
> on err, fmt.Println(err)  // doesn't stop the function
> on err, continue  // retry in a loop
>
> on err, goto label// labeled handler invocation
> on err, hname // named handler invocation
>
>
>
> And offers these possible extensions:
>
> on err, os.IsNotExist(err):  
> on err, err == io.EOF:   
> on err, err.(*os.PathError): // doesn't panic if not a match
>
> on err, : 
> on err:   // this pair provides if/else in 2 lines
>
> on err := f(),  // for assignment with single lvalue
>
>
>
> Other punctuation is possible, e.g. on (err) 
>
> Now if we could just convince the Go gods to prototype this along with
> try() in 1.14 :-)
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/golang-nuts/4Djft8snCjM/unsubscribe.
> To unsubscribe from this group and all its topics, 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/1b7ab9bd-0c1b-4658-8ee2-a36544b58f20%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKvHMgTYHEx5o%2Bxn8TSL6a46utuf%3DJn%2Boko-Dess6LbWBBWZnA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] `on err` alternative to `try()` has traction...?

2019-07-03 Thread Bakul Shah
May be indent(1) can be taught about Go syntax rules so that it can 
"pretty-print" ala Lisp?

> On Jul 3, 2019, at 3:25 PM, Michael Jones  wrote:
> 
> Any form of restraining gofmt has my vote. One that I despise is ruining:
> 
> switch v {
> case ‘a’: doA = true
> case ‘b’: doB = true
> :
> case ‘z’: doZ = true 
> }
> 
> Just had this two days ago. So sad to see it balloon up
> 
> On Wed, Jul 3, 2019 at 11:36 AM Aston Motes  wrote:
> This proposal is not very much different from a one-liner
> 
> if err != nil {  }
> 
> It's just 10 more characters. Granted, gofmt won't leave the one-liner 
> formatted that way, but it's not much more typing and comes with the benefit 
> of not needing a new keyword.
> 
> One variation on this proposal that is a little weird is that if could in the 
> case of checking for an error omit the requirement that its argument be a 
> boolean, giving
> 
> if err {  }
> 
> Which is only 3 characters longer than on and again avoids a new keyword. I 
> believe changing the behavior of if this way should be backwards compatible.
> 
> On Wed, Jul 3, 2019 at 6:26 AM Michael Ellis  
> wrote:
> I like this. A lot.
> 
> It's clean and explicit.  The reader only needs to understand that 'on' is a 
> test for a nil value (vs 'if' which tests for boolean true).
> 
> 
> 
> On Tuesday, July 2, 2019 at 3:57:24 PM UTC-4, Liam wrote:
> This proposal has attracted modest attention from the Go team...
> https://github.com/golang/go/issues/32611
> 
> It suggests:
> 
> err := f()
> on err, 
> 
> 
> on err, return err// any type can be tested for non-zero
> on err, return fmt.Errorf(...)
> 
> on err, fmt.Println(err)  // doesn't stop the function
> on err, continue  // retry in a loop
> 
> on err, goto label// labeled handler invocation
> on err, hname // named handler invocation
> 
> 
> 
> And offers these possible extensions:
> 
> on err, os.IsNotExist(err):  
> on err, err == io.EOF:   
> on err, err.(*os.PathError): // doesn't panic if not a match
> 
> on err, : 
> on err:   // this pair provides if/else in 2 lines
> 
> 
> on err := f(),  // for assignment with single lvalue
> 
> 
> Other punctuation is possible, e.g. on (err) 
> 
> Now if we could just convince the Go gods to prototype this along with try() 
> in 1.14 :-)
> 
> -- 
> 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/decc63a5-9e65-4e96-929f-76d44cf19e14%40googlegroups.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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CANfvvbVy1iP8Un8zudCwZhkTg5dQfGCrBkN-0VmFbbK-FgD8dA%40mail.gmail.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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CALoEmQy5E5%2BK%2BKAcCvVZFJDWptNdfkAz1NrSUVa4oM%3DuQxTgOQ%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2B981474-49D8-4889-9C39-8BC54D2BF886%40bitblocks.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] `on err` alternative to `try()` has traction...?

2019-07-02 Thread Liam
This proposal has attracted modest attention from the Go team...
https://github.com/golang/go/issues/32611

It suggests:

err := f()
on err, 

on err, return err// any type can be tested for non-zero
on err, return fmt.Errorf(...)

on err, fmt.Println(err)  // doesn't stop the function
on err, continue  // retry in a loop

on err, goto label// labeled handler invocation
on err, hname // named handler invocation



And offers these possible extensions:

on err, os.IsNotExist(err):  
on err, err == io.EOF:   
on err, err.(*os.PathError): // doesn't panic if not a match

on err, : 
on err:   // this pair provides if/else in 2 lines

on err := f(),  // for assignment with single lvalue



Other punctuation is possible, e.g. on (err) 

Now if we could just convince the Go gods to prototype this along with 
try() in 1.14 :-)

-- 
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/1b7ab9bd-0c1b-4658-8ee2-a36544b58f20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.