On Fri, 8 Aug 2008 12:47:48 -0300 "Gustavo Sverzut Barbieri" <[EMAIL PROTECTED]> babbled:
i agree here - this macro as a public header macro to be "commonly used" is not so hot an idea. :( > On Fri, Aug 8, 2008 at 11:20 AM, Enlightenment CVS > <[EMAIL PROTECTED]> wrote: > > > +#define EINA_ARRAY_ITER_NEXT(array, index, item) \ > > + for ((index) = 0; (index) < eina_array_count(array); ++(index)) \ > > + { \ > > + (item) = eina_array_get((array), (index)); > > + > > +#define EINA_ARRAY_ITER_END } > > NO, and this is a BIG NO. Guys, come on, this is the worst thing we > can do. Don't make macros like that, it is very error prone. Use > something like (untested): > > #define EINA_ARRAY_FOREACH(array, index, item) \ > for (index = 0, item = index < eina_array_count(array) ? > eina_array_get(array, index) : NULL; index < eina_array_count(array); > index++) > > EINA_ARRAY_FOREACH(array, index, item) { > code > } > > > remarks: > 1 - i haven't checked if eina_array_get() checks for out-of-bounds > indexes, I suppose it doesn't, so I did the first check. IMO doing > this check inside the FOR is useless, double-checking. > 2 - you don't need parenthesis around index and item, at least. > That is because you are assigning to them, thus making use of any > expression (the use of parenthesis), will make it invalid. If one > wants, for example, to use as item a pointer, he will have to add the > parenthesis himself anyway: *(v + idx). > > -- > Gustavo Sverzut Barbieri > http://profusion.mobi embedded systems > -------------------------------------- > MSN: [EMAIL PROTECTED] > Skype: gsbarbieri > Mobile: +55 (19) 9225-2202 > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > enlightenment-devel mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) [EMAIL PROTECTED] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs