Re:Show HN: Try/Catch/Finally experiment in Go
by manucorporat on Thursday August 14, 2014 @04:42PM
(#8179742)
I totally agree! just to leave it clear, I did not create it to be even used, it's an experiment.
I guess, it shows how powerful the panic(), recover(), defer can be, in my opinion much more than try/catch/finally.
A practical demonstration. Go even without explicit exceptions has the semantics needed to provide it exactly in the same way Java/C++ and Python does.
Re:Show HN: Try/Catch/Finally experiment in Go
by dead10ck on Thursday August 14, 2014 @04:49PM
(#8179777)
I'm truly not trying to be rude, but if you agree with the above point, then why did you make it publicly available? Only two outcomes can come of this:
1. Nobody uses it, for the reasons posted above.
2. People actually use it, which is bad, for the reasons posted above.
What you were trying to learn from this "experiment"? And what did you actually learn that is valuable to other people?
Re:Show HN: Try/Catch/Finally experiment in Go
by manucorporat on Thursday August 14, 2014 @05:05PM
(#8179861)
I am not trying to learn Go, I have been using it for years (without exceptions :) ) i believe clever hacks are usually helpful to open people's minds, don't you?
another examples, (not sure if you know objective-c). primitive type generics using macros + blocks: https://github.com/manucorporat/obme-ios/blob/master/obme.h
another example or a clever hack to break the limits ;)
Re:Show HN: Try/Catch/Finally experiment in Go
by PuerkitoBio on Thursday August 14, 2014 @05:55PM
(#8180067)
Maybe he did it for fun. Hacks don't have to be useful. Brad Fitzpatrick provided a Go solution to goal (https://github.com/eatnumber1/goal). Ken Thompson used to write quines (http://cm.bell-labs.com/who/ken/trust.html). No harm in doing so, especially when it is not wrongly marketed as some kind of useful problem-solving library.
As it is, they decided against it. Some may disagree with that, but the entire rationale is public and based on pragmatism. Go is a fairly opinionated language, so if you disagree strongly with those choices, you probably ought to pick another language. Part of the beauty and value of Go is that all Go code tends to read like all other Go code. Obfuscation and unnecessary abstraction are frowned upon.
In this case you can get much the same result with local functions and defer (which you are creating here anyway). There's little value in wrapping it up with this syntax other than to make your Go code less idiomatic.