Re: It pretty much falls into the 'unmaintainable crap' bin
Re: It pretty much falls into the 'unmaintainable crap' bin
Posted Dec 26, 2014 5:34 UTC (Fri) by ldo (guest, #40946)In reply to: Re: I won't bother to rewrite all of the code, so only for ParseColorTuple: by Cyberax
Parent article: The "too small to fail" memory-allocation rule
Come back when you’ve learned a bit more about programming.
Posted Dec 26, 2014 5:40 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link] (13 responses)
Or perhaps an audio codec? Nah, can't write those with gotos: https://git.xiph.org/?p=opus.git;a=blob;f=src/opus_encoder.c;...
Posted Dec 26, 2014 21:21 UTC (Fri)
by ldo (guest, #40946)
[Link] (12 responses)
While I’m sure it is quite complex code, it doesn’t seem to do much with dynamic storage: I found just two calls to opus_free in those 2500-odd lines.
While my example is half that size, it has 39 calls to PY_{,X}DECREF.
Come back when you can cope with that kind of complexity.
Posted Dec 26, 2014 21:25 UTC (Fri)
by Cyberax (✭ supporter ✭, #52523)
[Link] (11 responses)
Posted Dec 27, 2014 20:56 UTC (Sat)
by ldo (guest, #40946)
[Link] (10 responses)
Posted Dec 27, 2014 20:58 UTC (Sat)
by Cyberax (✭ supporter ✭, #52523)
[Link] (9 responses)
Posted Dec 27, 2014 21:43 UTC (Sat)
by ldo (guest, #40946)
[Link] (8 responses)
And while we’re at it, your tun.c example fails to recover if it cannot create its sysfs device files.
Posted Dec 27, 2014 22:01 UTC (Sat)
by Cyberax (✭ supporter ✭, #52523)
[Link] (7 responses)
The Linux kernel manages to do that just fine, somehow.
In particular, your block near line 480 will look like this:
And let me reiterate, your code is a mess. For example, you use 'break' to normally exit the outer loop from within the 'if' statement here: https://github.com/ldo/dvd_menu_animator/blob/master/spuh...
Why do you even bother with 'for' loops?
Posted Dec 28, 2014 6:29 UTC (Sun)
by ldo (guest, #40946)
[Link] (6 responses)
At least it works, unlike your code.
Pot calling the kettle black, as it were?
Posted Dec 28, 2014 6:31 UTC (Sun)
by Cyberax (✭ supporter ✭, #52523)
[Link] (5 responses)
Posted Dec 28, 2014 6:36 UTC (Sun)
by ldo (guest, #40946)
[Link] (4 responses)
Posted Dec 28, 2014 6:41 UTC (Sun)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
If you can make a reasonable description of what it does - I can guarantee that it's possible to write it far cleaner then what you have.
Posted Dec 28, 2014 21:33 UTC (Sun)
by ldo (guest, #40946)
[Link] (2 responses)
Posted Dec 28, 2014 22:37 UTC (Sun)
by Cyberax (✭ supporter ✭, #52523)
[Link] (1 responses)
Posted Dec 29, 2014 17:26 UTC (Mon)
by ldo (guest, #40946)
[Link]
What’s good for the goose, eh?
Posted Dec 26, 2014 16:14 UTC (Fri)
by mb (subscriber, #50428)
[Link] (5 responses)
This is like the guy complaining about _all_ those damn ghost drivers on the highway.
Huge projects use goto for error handling successfully. See the Linux kernel for instance.
Posted Dec 26, 2014 21:15 UTC (Fri)
by ldo (guest, #40946)
[Link] (4 responses)
Posted Dec 27, 2014 11:32 UTC (Sat)
by mb (subscriber, #50428)
[Link] (3 responses)
Posted Dec 27, 2014 20:40 UTC (Sat)
by ldo (guest, #40946)
[Link] (2 responses)
Posted Dec 27, 2014 23:14 UTC (Sat)
by vonbrand (guest, #4458)
[Link] (1 responses)
The pseudo-loops hide the error processing in a structure that could be anything else, and which BTW I haven't seen anywhere else either. ln comparison, the "label: <error handling code>" pattern is easy to spot.
Posted Dec 28, 2014 6:33 UTC (Sun)
by ldo (guest, #40946)
[Link]
Re: It pretty much falls into the 'unmaintainable crap' bin
Like... I don't know, say an OS kernel?
Re: Or perhaps an audio codec?
Re: Or perhaps an audio codec?
Re: Your wish is my command
Re: Your wish is my command
Re: What do you mean by "with a loop"?
Re: What do you mean by "with a loop"?
No you don't. Just split them up into free-standing functions, instead of 300-line monstrosities.
https://gist.github.com/Cyberax/3a7796231be66d0f64cc
(no, I'm not going to check it in details). It's pretty clear that simply by splitting some logic into a function you can decrease nesting level by 3.
Re: And let me reiterate, your code is a mess.
Re: And let me reiterate, your code is a mess.
Re: I have not claimed that my code works
Re: I have not claimed that my code works
Re: If you can make a reasonable description of what it does
Re: If you can make a reasonable description of what it does
Re: Please, provide a coherent description
Re: It pretty much falls into the 'unmaintainable crap' bin
And your "nested pseudo loops error handler" argument is void, because thouse unmaintainable monsters should be split into sub-routines anyway. And then it can use plain gotos. Which gains the additional opportunity to write structured error paths instead of "one must handle all errors" error paths.
Re: Huge projects use goto for error handling successfully
Re: Huge projects use goto for error handling successfully
Your complex pseudo-loop can't help here at all. It just adds extra complexity. The error paths will still be untested.
Re: The error paths will still be untested.
Re: The error paths will still be untested.
No, the cleanups always happen after the do-once constructs. That’s how you can be sure they will always be executed.
Re: The pseudo-loops hide the error processing