On Mon, Jan 21, 2013 at 9:31 AM, Tom Hacohen <[email protected]> wrote:
> On 21/01/13 11:22, Cedric BAIL wrote:
>> On Mon, Jan 21, 2013 at 7:39 PM, Gustavo Sverzut Barbieri
>> <[email protected]> wrote:
>>> This macro declares a variable and do a mix of do-while split into two
>>> macros that will likely cause errors. Why did you choose that over let user
>>> declare the variable, avoiding the do-while?
>>
>> Because you need to execute something at the end of the block anyway.
>> I first tried with a for, but it's even more error prone in fact.
>
> Yes, this is way cleaner than the for alternative.
>
> Gustavo: the whole point is that it'll cause errors if you don't use it
> correctly.
i understand it, but this code is expected in this usage:
if (changed)
begin(write_ptr);
something();
if (changed)
write_ptr->bla = newval;
somethingelse();
if (changed)
end(write_ptr);
which won't work and users will have a hard time to figure out why. I
know this pattern is not the best, yet we have lots of development
like that.
Alternatively we could take a callback and do the work inside it, then
it would be eina_cow_change(cow_mem, change_cb, ctx), inside change_cb
you get the to-write memory, change it and it will automatically call
done(). You can even implement return true/false in change_cb() to do
rollback or just ignore (assume memory wasn't changed).
--
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [email protected]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel