'Kerfuffle' Erupts Around Newly-Proposed try() Feature For Go Language (thenewstack.io) 210
Matt Klein, a member of the Go steering committee recently apologized for the angst caused to some people by "the try() kerfuffle... Change is hard, but sometimes it's for the best."
Tech columnist Mike Melanson covers the kerfuffle over the newly-proposed feature, while trying "not to over-dramatize what is happening." There is disagreement and conflicting views, but working through those views is how the open source sausage is made, is it not? Of course, in the Go community, how the core team receives those opposing views may be a point of soreness among some who vehemently opposed the vgo package versioning for Go and felt that, in the end, it was rammed through despite their objections. As one Gopher points out, it is better to debate now than summarily accept and then later deprecate...
As Go makes its way to Go 2.0, with Go 1.14 currently taking center stage for debate, there is, again, as Klein points out, some kerfuffle about a newly proposed feature called try(), which is "designed specifically to eliminate the boilerplate if statements typically associated with error handling in Go." According to the proposal, the "minimal approach addresses most common scenarios while adding very little complexity to the language" and "is easy to explain, straightforward to implement, orthogonal to other language constructs, and fully backward-compatible" as well as extensible for future needs.
Much of the disagreement around try() comes in the form of whether or not the resultant code is more or less readable than current implementations of error handling. Beyond that, however, some say that even if try() were accepted, it has faults that would prevent them from recommending or even allowing its use among their teams. Meanwhile, another point of contention is offered in an open letter to the Go team about try by William Kennedy who often writes about Go, and focuses on not style or function, but rather whether or not a solution is needed at all. According to Kennedy, "the perceived error handling complaints are perhaps overblown and these changes are not what the majority of Go developers want or need" and that try() may be a solution searching for a problem, and even the cause of more problems than it solves."Since this new mechanic is going to cause severe inconsistencies in code bases, disagreements on teams, and create an impossible task for product owners to enforce consistent guidelines, things need to be slowed down and more data needs to be gathered," Kennedy writes.
He goes on to point out those very sensitivities that may have lingered from previous discussions in the Go community. "This is a serious change and it feels like it's being pushed through without a concerted effort to understand exactly what those 5% of Go developers meant when they said they wanted improved error handling...."
Tech columnist Mike Melanson covers the kerfuffle over the newly-proposed feature, while trying "not to over-dramatize what is happening." There is disagreement and conflicting views, but working through those views is how the open source sausage is made, is it not? Of course, in the Go community, how the core team receives those opposing views may be a point of soreness among some who vehemently opposed the vgo package versioning for Go and felt that, in the end, it was rammed through despite their objections. As one Gopher points out, it is better to debate now than summarily accept and then later deprecate...
As Go makes its way to Go 2.0, with Go 1.14 currently taking center stage for debate, there is, again, as Klein points out, some kerfuffle about a newly proposed feature called try(), which is "designed specifically to eliminate the boilerplate if statements typically associated with error handling in Go." According to the proposal, the "minimal approach addresses most common scenarios while adding very little complexity to the language" and "is easy to explain, straightforward to implement, orthogonal to other language constructs, and fully backward-compatible" as well as extensible for future needs.
Much of the disagreement around try() comes in the form of whether or not the resultant code is more or less readable than current implementations of error handling. Beyond that, however, some say that even if try() were accepted, it has faults that would prevent them from recommending or even allowing its use among their teams. Meanwhile, another point of contention is offered in an open letter to the Go team about try by William Kennedy who often writes about Go, and focuses on not style or function, but rather whether or not a solution is needed at all. According to Kennedy, "the perceived error handling complaints are perhaps overblown and these changes are not what the majority of Go developers want or need" and that try() may be a solution searching for a problem, and even the cause of more problems than it solves."Since this new mechanic is going to cause severe inconsistencies in code bases, disagreements on teams, and create an impossible task for product owners to enforce consistent guidelines, things need to be slowed down and more data needs to be gathered," Kennedy writes.
He goes on to point out those very sensitivities that may have lingered from previous discussions in the Go community. "This is a serious change and it feels like it's being pushed through without a concerted effort to understand exactly what those 5% of Go developers meant when they said they wanted improved error handling...."
Funny how error handling keeps oscillating (Score:3, Insightful)
Fro decades now error handling has seen so many forms, from exceptions, to return values, to special return types that wrap either results or errors depending on which you have, to in-out error params that get populated on result of an error...
It all just seems to go around and around again. And even mechanisms that are supposed to force people to handle errors seem to end up a lot of time in println.
Re:Funny how error handling keeps oscillating (Score:5, Insightful)
If you are writing OS code, you need to know when an error happens, and you need to deal with it. For that use case, return values work well, and unchecked exceptions are very, very hard to use effectively (so difficult that when Microsoft wrote a kernel in C#, they added checked exceptions to the language).
So there's no error reporting mechanism that fits every use case perfectly. And even in the best case, error handling code is a pain and rarely tested.
Re: (Score:3)
Re: (Score:2)
99% of the case when you're processing a 'POST' - that is, you're going to process and store the results - you probably need to write a whole fallback/rollback process (which the frameworks are generally shitty at, go figure.)
That's something that memory transactions could theoretically help you with, yet vendors like Intel apparently screwed up their hardware that was supposed to do that.
Re: (Score:2)
Memory may very well be the most expensive resource to unwind and/or secure from concurrency effects relative to the cost of not having an unwinding option and/or concurrency safety, so it's currently the more pressing issue.
Also, the C++ masturbation is getting old by now.
Re: (Score:2)
Tearing down threads, work queues or a network-backed user session is more difficult
Funny how Go (which I have to note I'm not even a fan of!) got around the need for "taking down threads" by...not taking them down. C++ has such shitty concurrency that it's not even funny anymore in the 21st century.
Re: (Score:2)
Re: (Score:3)
99% of the case when you're processing a 'POST' - that is, you're going to process and store the results - you probably need to write a whole fallback/rollback process
If your framework rolls back transactions on exceptions, then 95% of the time you don't have to worry about it. Occasionally there are more complex POSTs that also need complex error handling, but those are rare.
Of course, if your framework doesn't roll back transactions on exceptions, then you need to write that code yourself.
Re: (Score:2)
which the frameworks are generally shitty at, go figure.
In Java they are excellent, e.g. spring-boot. But it has other drawbacks where I wonder who was involved in the design.
Re: (Score:2)
Re: (Score:2)
> I think the point was that POSTs are supposed to have observable side effects
There is no "supposed" in practice. That's a subjective philosophical statement about protocol use. The backend processing is necessarily opaque, despite the version of REST you believe is "appropriate".
Re: (Score:2)
It's more than that even (Score:3)
The problem is there are different error mechanisms for different use cases.
I think it's even more complex than that as there are also different desires at different times to say what should truly "handle" an error - should it just go to a log? Should it go to the person using the application to pass along to someone else? Should it be rigorously handled and alternative code run instead as a backup, that may itself fail? And all of it, maybe it needs to be decided dynamically...
I've seen people use excep
Re: (Score:2)
I've seen people use exceptions for all kinds of error handling, to pass stuff back up to the top level and also just in-module error capture and consumption.
The big problems with exceptions as an error handling mechanism is that over time they stop being used for only exceptional conditions and start being used as something much closer to general flow control.
For instance even if the stream object has a method that answers "is there any data left?" a heavyweight try/catch exception handling scheme is used instead and becomes the "norm" even though that lightweight "is there any data left?" function works for almost all use cases.
Another case case is a func
Re: (Score:2)
That's a great point, I've also seen systems that use exception handling for flow control and not just errors.
Re: Funny how error handling keeps oscillating (Score:2)
That's completely wrong.
Whether to use exceptions or error codes is a matter of what your invariants are.
if your invariant is "I'm never in an error state" then you have to use exceptions, because return codes only allow you to notify the caller something bad happened, as opposed to making sure state cannot be propagated and the stack is unwound.
Re: (Score:2)
Windows Update (Score:2)
try() {
installwindows.exe
} catch(exception e) {
e = null;
Msgbox.show("Something went wrong! Good luck figuring out what it was, LOL");
}
Re: (Score:2)
Re: (Score:2)
The problem is there are different error mechanisms for different use cases. For example, if you're writing web APIs, then you mostly don't care what the error is, you can just let the exception float up to the top and return an error to the client or whatever. Maybe log something. Exceptions are really nice for that use case, really easy to write code with.
If you are writing OS code, you need to know when an error happens, and you need to deal with it. For that use case, return values work well, and unchecked exceptions are very, very hard to use effectively (so difficult that when Microsoft wrote a kernel in C#, they added checked exceptions to the language).
This distinction is only made because on a networked system, it is basically impossible to handle all errors. Once you're not handling a bunch of errors, it's super easy to not handle another error, in a self-reinforcing way. That doesn't mean it's a correct decision, it just means you gave up and decided to ship crappy software. You can always fix it with a patch rollout, right?
[Sigh. I realize that that last might float past people - you can try to fix it, but if your development culture floats except
Re: (Score:2)
Re: Funny how error handling keeps oscillating (Score:2)
That's stupid.
Suppose you have a server listening in on TCP sessions. While processing a message on a session, an unspecified error occurs.
If you throw an exception, that exception can be caught by the server, which will correctly tear down the session and keep on accepting connections from other clients.
Or you could even decide to catch it in the session handler itself, and just reject that message and keep and accepting others.
If you just exit, you stop everything, and don't even tear down gracefully. Hel
Re: (Score:2)
Errors are hard: I'm trying to put together an analysis of error propagation (not handling!) as a safety-critical system, to follow up to A Discipline of Errors [wordpress.com]
Comments, corrections and well-hurled brickbats are cordially invited!
Re: (Score:2)
Re: (Score:2)
Thanks, it's a bit short at the moment but a good start and brings up some interesting points.
Re: (Score:3)
I think "error" handling is often the wrong term, it's "exception" handling normally. Ie, reaching the end of a file is not an error. So even with some advanced features like exception handing I see many programmers resort to assuming it's just for errors. I also see a tendency in that new ways of handling either errors or exceptions can be done even more clumsily than classical return code error handling, such as just having a single catch-all handler on the outermost loop (not error-handling per se but
Re: (Score:2)
You forgot setting a global value to a non-zero value, that would get overwritten each call that might generate an error.
Re: Funny how error handling keeps oscillating (Score:4, Funny)
Hey man at least mine was not another Yoda post.
Or, rather: "Yoda post, another mine was not."
Re: (Score:2)
Re: first world problems (Score:2)
Small minded managers gonna save a buck.
Savin' a buck gonna produce copious bugs.
Copious bugs gonna breach yo' security.
All your data are belong to us!
Wasn't this settled a long time ago? (Score:5, Funny)
Re: (Score:2)
Do or do not!
Was Yoda a secret fan of non-deterministic programming languages?
Re: (Score:2)
Re: (Score:2)
" Do or do. Not! There is no. Try!"
That was a lot of effort lol
Re: (Score:2)
"Go or Go not! There is no TRY!" — Yoda
Fixed that for you.
Re: (Score:2)
"do while or do while not, there is no try/catch."
Alright already! We get it... now knock it off (Score:4, Insightful)
The word author the author learned today was obviously "kerfuffle", given he chose to use it a half dozen times.
Maybe someone should teach him about the word "thesaurus".
Re: (Score:2)
Re: (Score:2)
93 Escort Wagon: Yeah, I'll have to agree with the walking thesaurus on that one.
Mike Melanson: Do not ever call me a thesaurus.
93 Escort Wagon: It's just a metaphor, dude.
Slashdot: Editors are completely literal, metaphors are gonna go over their heads.
Mike Melanson: Nothing goes over my head. My reflexes are too fast. I would catch it.
Re: (Score:2)
"I felt a great covfefe in the force." That works better.
African or European Try()? (Score:2)
Normally, I'd just call ItsOnlyAFleshWoundComeBackHere()
These old bones (Score:2)
Thedinosaur.
Actually, a hurly-burly (Score:5, Funny)
Technically, this is less of a kerfuffle than a brouhaha. A to-do, if you will. Less than a donnybrook, but more than a mere hoo-ha.
Re: (Score:3)
Technically, this is less of a kerfuffle than a brouhaha. A to-do, if you will. Less than a donnybrook, but more than a mere hoo-ha.
I was going to say it was a dust-up, then I changed my mind to hubbub, but now I'm split between fuss and commotion.
Seems more like a knicker twister to me... (Score:2)
... but it definitely has some of the characteristics of undie bunching.
try allows for much custom and robust errors (Score:5, Informative)
Basically this is your code with try/catch (any language):
try {
do_thing_1();
do_thing_2();
do_thing_3();
} catch {
print_error("Something happened in 1, 2 or 3");
die("Fatal error");
}
This is your code in Go:
result = do_thing_1();
if (result == failed) {
print_error("Something happened in 1");
die("Fatal error");
} else {
result2 = do_thing_2();
if (result2 == failed) {
print_error("Something happened in 2");
die("Fatal error");
} else {
result3 = do_thing_3();
if (result2 == failed) {
print_error("Something happened in 2");
die("Fatal error");
}
}
}
Re:try allows for much custom and robust errors (Score:5, Informative)
Finally, the try{}catch{} example you gave doesn't have anything to do with the feature proposed here in Go.
Re: (Score:2)
Yes, I know you can avoid the else clauses but it sacrifices readability/consistency. Perhaps you can condense the two, perhaps not, in many cases you do not want to die on printing an error. It largely depends on your circumstances.
I'm also aware of the fact that Go's implementation of "try" will be 'slightly' different than just about any other language that implements a try statement, just for readability and to avoid confusion, I'm sure.
Re: (Score:2)
I'm also aware of the fact that Go's implementation of "try" will be 'slightly' different than just about any other language
It's drastically different. It doesn't even implement the same functionality. The only similarity is that they both deal with error handling code.
Re: try allows for much custom and robust errors (Score:2)
Re: (Score:2)
So illuminate it? I'm not following the problem here.
Re: (Score:2)
Note of course that your example had an error in it.
The main benefit of exception based code is it's brevity when compared with the equivalent return-, wrapper-, or parameter-based error codes. The benefits of return-based codes are their specificity and flexibility. Wrapper-based errors are useful where an existing protocol can't be changed. Error parameters are about the same as returned error codes but are even more bulky code-wise. Different return targets have a linguistic overhead of supporting labels
Re: (Score:2)
Re: (Score:2)
Pointless, you need to say where it crashed or include an error code at the very least. However it's better to actually handle the error rather than throw your hands in the air. There is often need for code that does not fail so easily and is more robust when encountering errors. After all, customers may be annoyed that their television crashed and is taking a few minutes to reboot; and extremely put out when their automobile engine decides that it's time to throw UnknownError.
If you're talking to external, systems and stuff.. (Score:2)
... try is great. Deals elegantly with what you cannot depend on.
If you're calling try on your own code... well, where do I start.....
Re: (Score:2)
If you're calling try on your own code... well, where do I start.....
You start out by pointing out that its in the name "exception handling" ... It is for handling things of an exceptional nature, not general flow control.
Re: (Score:2)
try is great. Deals elegantly with what you cannot depend on.
That’s a very nice description of what try() is for. But it most definitely applies to your own code too. Or at least to mine: I’m not arrogant enough to think my own code is error-free or capable of dealing with every eventuality. But as others have stated elsewhere, I do not use try() for flow control. And I certainly do not test with serious errors being silently caught that way.
Re: (Score:2)
if ( ((res = func1()) != ok) || ((res = func2()) != ok) || ((res = func3()) != ok) )
{
print_error(res);
die(res);
}
Goes Go not allow something like that?
Also this try() function is a bit different to the example you gave. Basically functions in Go return an error as the last parameter by convention, and it just condenses the if() and error handling into try(func()).
throw(RTFA) (Score:2)
Unless I'm reading this [github.com] wrong, that isn't what is proposed. The "try()" statement for Go doesn't seem to be true "exception handling" as shown in the first example above, but more syntactic sugar for the second 'check the return of every function' example. In good old-fangled C you'd do:
#define TRY(f) if ( (f) == EOF ) { return( EOF ) }
(except using Go's facilities for functions to return a list of values, with the last one being an error flag (which does sound a useful technique). I'm not a Go progr
Re: (Score:2)
Basically this is your code with try/catch (any language):
That example is wrong.
try {
do_thing_1();
do_thing_2();
do_thing_3();
} catch {
print_error("Something happened in 1, 2 or 3");
die("Fatal error");
}
It should look more like this.
try {
do_thing_1();
do_thing_2();
do_thing_3();
} catch (Exception1 ex) {
print_error("Something happened in 1
Re: (Score:2)
Yeah,
I was considering to try http://freepascal.org/ [freepascal.org] to experiment a bit. It seems it is the only right language to build cross platform applications for all 3 Desktop OSes and Android as well as iOS. Not sure if they have portable GUI libraries though, I believe to remember they integrate with Qt.
Almost no GO (Score:2)
I've worked in many large projects and company. I've seen very little GO usage. The main exception is where somebody felt like trying it and nobody found out about it until it was deployed. In other words, it's bottom up, without any management decision as to whether or not it is good for the organization. Usually management is pissed off because they perceive it as a new and unnecessary support headache.
Re: (Score:2)
Whereas my management looks at it and said "Wow, Communicating Sequential Processes in a non-academic language"
And yes, I do pick my companies based on who's running them as much as what they're doing. I even chased Jacob Slonim around for a couple of years until I could get a job with him, rather than at a company he'd left (;-))
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
It's also becoming more popular as a backend language. People start with Python, Javascript, or Rails on the backend, but soon realize static typing makes things a LOT easier once you have a bigger team. Then the question is what do you use? If you don't want to use
Re: (Score:2)
The same devops that insist on building a 15M static binary in a container to avoid "dependency" issues because they're too stupid to architect around properly versioned libraries?
Ya, I don't take them seriously either.
Re: Almost no GO (Score:2)
Re: (Score:2)
I wrote some toy programs in it, really tried to like it. But this language... it's not for professional developers. It's for wannabes. With all its in your face flaws and weird matters of taste... that is, Rob Pike's taste, fuck you malcontent users... it would have been completely forgotten by now, except Google. Conferred some kind of respect it doesn't deserve. Google couldn't possibly hatch a flightless turkey could they? Google is populated by nothing but smart people, right? Right?
Check out Rust. An
NO! (Score:2)
try() not!
do() or do not()!
There is no try()!
Disgusting hack of a feature (Score:2)
I must say, my opinion of Rob Pike and Ken Thompson took a major dive when I looked at this supposed "feature". Oh yeah, change is hard, change for the worse is harder. But looks like Go for me is just Gone. Wake me up if it ever gets generics. Instead it gets halfassed syntactic sugar like try, at that same time polluting the well known try ... catch pattern with something that isn't even remotely like it. Even a highschooler could do better. Thxbai.
Yoda already weighed in on this (Score:2)
Go is still a toy then (Score:2)
I consider error handling a solved problem, and I'd expect any "new" language to have solved it as well. No need to try this one for now.
Re: (Score:2)
Very much so. The "Second System Effect" or rather "Gold Plating" basically. A very old fail in software construction.
Re: (Score:2)
It is very hard to find ANY software that isn't significantly worse than it used to be, due to adding all sorts of new "features" that nobody wanted or asked for.
Common Lisp? ;)
Re: (Score:2)
"[language]developers who think it's fun to implement a new feature...The blowback is from the users who actually have to use the langauge from work,"
After reading through the comments on the feature request, that seems like a good characterization of the situation.
Re: (Score:2)
This 'feature' is not "exceptions," it's not a try{}catch{} block that you'll see in most languages, it's a little piece of syntactic sugar, to save two lines of code. Golang is a sparse language on purpose, and adding these kinds of syntactic sugar do not fit it well.
Every piece of syntactic sugar has a corresponding memory load on your brain. C++ added so many features over time, that you can no longer learn the language in seven days, or
Re: (Score:2)
Every piece of syntactic sugar has a corresponding memory load on your brain. C++ added so many features over time, that you can no longer learn the language in seven days, or seven weeks.
You can't learn C either in 7 weeks. I mean you can grasp the syntax and most of the mechanisms, but you're nowhere near the point you can be released on a code base without supervision. Some people seem never to be able to get pointers.
C++ is the same in that it has that all underneath, so you can't claim to know really
Re: (Score:2)
Some people seem never to be able to get pointers.
That's a problem of the teacher.
Re: (Score:2)
Only up to a point. If the teacher fails to teach, it could well be their fault. If the pupil goes out into industry for years, becomes a professional and still fails to learn it's not the teacher's fault.
It's about how you *use* the language (Score:2)
You can use c++ as if it were c with classes and objects. If you use it that way, then that's what it is. If you do that, it can still be learned in a short time (a very short time if you already know c) and it is enormously better than c, which would have us make do with structs for objects (which works, but is very clumsy) and the whole class thing, as Monty Python
Re: (Score:2)
You can use c++ as if it were c with classes and objects. If you use it that way, then that's what it is. If you do that, it can still be learned in a short time
Your point is true, but then people will tell you that you're using it wrong, and your coworkers will use the weird features. Incidentally, last month I saw someone using 'friend' in new code. I thought that was interesting.
it is enormously better than c
Not really, because inheritance turns out to be enormously overrated. In some cases it's a useful way to share code, but mostly it's not, and ends up in overarchitected systems.
Re: (Score:2)
Human beings have conflicting needs/wants. Always have, always will.
In barbaric societies, conflicts are resolved by tyrany, violence, war, and bloodshed.
In civilized societies, conflicts are resolved by compromise.
Those users that whine and bitch that their precious workflow is being disrupted, do they realize that there are people that actually made this language that's at the heart of their precious workflow, that these people labored over this language, and that these people have motivations of their ow
Re: (Score:2)
It seems that you picked up on the strong "entitlement" vibe too.
It is my opinion that if this is such a huge deal, they are thinking about it wrong from the very beginning. In fact, I would say that whole concept of error handling is broken and is being handled in entirely the wrong way. But meh. There are no words that can help someone think of something they have never thought of before.
TL;DR, think carefully and be prepared to move your viewpoint around if you want to avoid intrinsically silly error han
Re: (Score:2)
You consistently use way too many all caps and bold. Pretty much none of it is required.
Associated with mental illness and crackpottery, btw, APK.
Re: (Score:2)
You consistently use way too many all caps and bold. Pretty much none of it is required.
Associated with mental illness and crackpottery, btw, APK.
His nuttery is amusing, but after you see a few dozen (or hundred) of his posts you realize his behavior really is indicative of mental illness.
Is it a simple obsession, or does it rise to the level of a genuine obsessive-compulsive disorder?
Re: (Score:2)
Lol, what are you babbling about?
Never mind, I don't really care.
Re: (Score:2)
*yawn*
Re: (Score:2)
* yawn *
Re: (Score:2)
Here you go, douchebag, since you're too stupid to google it yourself:
Bypass the Windows Login prompt
1. Let Windows boot to the login screen and make note of the User Name that is displayed above the password entry box. In this example we'll assume the name is "Bob".
2. Reboot the PC and let Windows start to boot (when you see the Windows startup prompt).
3. As soon as you see the Windows startup prompt, turn off the PC by
Re: (Score:2)
Your are too dumb to converse with.
I have no idea what you're babbling about, I showed you how to bypass the Windows Login screen and now you're off like a douche to something else entirely.
I never said anything about root kit removal or registry values, I said there was a way to bypass the Windows Login screen, and there it is.
Now please, continue with your unhinged rant.
Re: (Score:2)
You lost but you just don't have the balls to admit it. :) lol
Plus you're obsessed with me.
Re: (Score:2)
Definite delusions of grandeur
More like delusions of adequacy.
Re: (Score:2)
Still too many unnecessary all caps.
Why?
Re: (Score:2)
I really like the try/catch/finally model in theory, and I like knowing what error conditions I need to anticipate, say, with Java checked exceptions.
But in practice I find exceptions are usually truly catastrophic conditions where cancelling an entire operation, if not exiting the programme altogether, is the best response. Or that the exception was something that would only be raised if there is an actual bug where bad data slipped through, such as input not validated properly, and then what I really wan
Re: (Score:2)
There's just three kinds of errors really.
1) Errors resulting from programming mistakes (divide by zero, null pointers, assertions) and things you can do nothing about (out of memory), but also syntax errors and key violations (returned from SQL server) or 4xx errors from web servers.
Log these with the highest error level, and create tickets for them to get them solved. They're problems introduced by bad code, insufficient testing whatever. For simple apps, just exit, for server apps, kill whatever reques
Re: (Score:3)
Hence why most programs have a try/catch/throw/finally so you can deallocate something regardless of whether there was success or failure.
Your resource handling and business logic should also be in separate try/catches so you don't get confused as to what you're doing at any particular time. Ideally in your example, you would write a function that you call every time you need to alloc() and every time you de-alloc() that does all the reference counting and sanity checking for you. Or use a language (eg. Obj
Re: (Score:2)
{
bool fail = 0;
allocate memory;
try { do something; } catch (exception) { fail = 1; }
deallocate memory;
if (fail)
handle it;
}
Re: (Score:2)
Or if you have RAII and destructors, the code becomes:
allocate memory/handle/resource/whatever;
do something;
Re: (Score:2)
The more code a programmer writes the more productive they are.
I'm sorry, but I hope we never work at the same company. Please don't take it as a criticism, maybe your approach is right and mine is wrong.