On Thu, Jul 5, 2012 at 3:38 PM, Tim Mayberry <span dir="ltr"><<a href="mailto:mojofunk@gmail.com" target="_blank">mojofunk@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Thu, Jul 5, 2012 at 1:37 PM, Paul Davis <<a href="mailto:paul@linuxaudiosystems.com">paul@linuxaudiosystems.com</a>> wrote:<br>
><br>
><br>
> On Wed, Jul 4, 2012 at 11:31 PM, Razvan Cojocaru <<a href="mailto:razvanco@gmx.net">razvanco@gmx.net</a>> wrote:<br>
>><br>
>> >> 1) recursive mutexes are not acceptable. google around for decades-old<br>
>> >> criticisms and the story of how they came to be part of pthreads.<br>
>> ><br>
>> > +1 !!<br>
>><br>
>> OK, so recursive mutexes are off-limits, but gotos are OK. :D<br>
><br>
><br>
> goto's as a mean of avoiding multiple exit points from a function without<br>
> creating excessively complex nested conditionals are definitely OK. gotos as<br>
> a means of restarting a loop under odd conditions is not ideal since it can<br>
> normally be done better without them, but sometimes  it just feels right.<br>
><br>
<br>
</div></div>To me it seems like many of the uses of goto in the ardour source<br>
result from a more "C style" of programming and with a little<br>
refactoring many could be removed if that was a goal.<br>
<br>
I had a rough go at it this afternoon and removing about 20 out of the<br>
first 25 or so I encountered in libardour was fairly straight forward:<br>
<a href="https://github.com/mojofunk/ardour3-mingw/commits/goto" target="_blank">https://github.com/mojofunk/ardour3-mingw/commits/goto</a><br>
<br>
about 30 less lines of code too.<br>
<br>
One other "C style" practice I notice a lot is using an int as a<br>
return type to indicate success(0)/failure(-1) rather than<br>
bool(success=true, failure=false). I find this a little confusing<br>
sometimes when reading through the code being more used to C++ style.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.</font></span></blockquote><div><br></div><div> I also think most of the gotos could be removed by using RAII more.</div><div><br></div><div>I took a quick look at what you had done (just a couple of change sets), and noticed at least one error: you used scoped_ptr with new[], which will end up calling delete, instead of delete[] in the scoped_ptr's destructor. You should have used scoped_array instead.</div>
<div><br></div><div>-Sakari- </div></div>