Re: [go-nuts] Error Handling Question

2022-10-24 Thread Ian Lance Taylor
On Mon, Oct 24, 2022, 9:03 PM robert engels wrote: > Totally understandable, but then I think the Go team should also drop any > proposals related to “improved error handling” - because you are going to > arrive back where you started - maybe with the a slightly different syntax > and that hardly

Re: [go-nuts] Error Handling Question

2022-10-24 Thread robert engels
Totally understandable, but then I think the Go team should also drop any proposals related to “improved error handling” - because you are going to arrive back where you started - maybe with the a slightly different syntax and that hardly seems worth the effort. Great engineering is built by sta

Re: [go-nuts] Error Handling Question

2022-10-24 Thread Ian Lance Taylor
On Mon, Oct 24, 2022 at 8:49 PM Robert Engels wrote: > > I’ve read that many times and I don’t believe it holds much water. Even the > example cited about handling the inability to open a file - the function > can’t handle this because it does not know the intent which leads to the > > If err !=

Re: [go-nuts] Error Handling Question

2022-10-24 Thread Robert Engels
I’ve read that many times and I don’t believe it holds much water. Even the example cited about handling the inability to open a file - the function can’t handle this because it does not know the intent which leads to the If err != nil { return err } boilerplate. This is exactly what checke

Re: [go-nuts] Error Handling Question

2022-10-24 Thread Ian Lance Taylor
On Mon, Oct 24, 2022 at 5:57 PM Robert Engels wrote: > > But that highlights the value of exceptions - the non error path is very > clean. For example when writing a file - it often doesn’t matter the reason > it failed within the write function - could be an invalid path, illegal file > name ,

Re: [go-nuts] Any information about adding a trailing comma in ast CompositeLit (for structs)

2022-10-24 Thread Tajmeet Singh
Thanks for looking at it :smile: Could you elaborate more on how the `SetLines` would work on a `token.FileSet`? I thought that `SetLines` is only for the `os.File` types :sweat: Do you mean that I should create offsets (using SetLines) before I create the FileSet out of it? reference code:

Re: [go-nuts] Error Handling Question

2022-10-24 Thread Robert Engels
But that highlights the value of exceptions - the non error path is very clean. For example when writing a file - it often doesn’t matter the reason it failed within the write function - could be an invalid path, illegal file name , out of disk space. If the code is properly decomposed that fun

Re: [go-nuts] Any information about adding a trailing comma in ast CompositeLit (for structs)

2022-10-24 Thread David Finkel
On Sat, Oct 22, 2022 at 10:00 PM Tajmeet Singh wrote: > Hello, > > I've been working on a utility to generate constructors for me when I > provide it with a path to the file containing the struct and it `Ident`. > The idea was that I would just create a ast.Node (FuncDecl) with all the > necessar

Re: [go-nuts] Error Handling Question

2022-10-24 Thread Ian Lance Taylor
On Sun, Oct 23, 2022 at 9:31 PM 'Daniel Lepage' via golang-nuts wrote: ... > 3. Streamlining shouldn't only apply to error handling that terminates the > function. > > Unlike panics, errors are values, and should be treated as such, which means > that the calling function should be able to de

Re: [go-nuts] Error Handling Question

2022-10-24 Thread 'Axel Wagner' via golang-nuts
ISTM that a lot of your arguments boil down to throwing two disparate things into the same pot: 1. Detecting and handling failure modes outside the current process, which have to be expected and should be dealt with gracefully by a correct program. 2. Limitations of Go's type system, which result i

Re: [go-nuts] Re: Error Handling Question

2022-10-24 Thread Andrew Harris
> In many cases, including in the standard libraries, there are functions that return errors and then accompanying functions with names like MustFoo() that just call Foo() and panic if there's an error. At least inside the standard lib, the uses of MustXxx document why they behave the way they

Re: [go-nuts] Re: Error Handling Question

2022-10-24 Thread Robert Engels
Dan, If it walks like a duck… You make a great case why Go should have checked exceptions. If anything the Go error handling model tries to be checked exceptions - every error should be explicitly handled - without any of the conveniences of exceptions - common blocks, stack traces and call st

[go-nuts] Re: Error Handling Question

2022-10-24 Thread Harri L
Hi, On Friday, October 21, 2022 at 12:14:52 AM UTC+3 dple...@google.com wrote: > > var x0 float > try { >x0 = check DoSomeMath(check FetchSomething(), check ComputeSomething()) > } handle err { >log.Info("Unable to estimate initial approximation, defaulting to 1...") >x0 = 1 > } > //

Re: [go-nuts] MPEG-1 Video decoder, MP2 Audio decoder and MPEG-PS Demuxer in pure Go

2022-10-24 Thread Dimas Prawira
Nice Milan, thank you for sharing this. Regards On Sun, Oct 23, 2022 at 11:23 PM Milan Nikolic wrote: > A simple way to get video playback into your app or game. > https://github.com/gen2brain/mpeg > > There is also a live web example here https://gen2brain.github.io/mpeg. > The CPU usage is