hash iteration macros proposal

luben luben at unixsol.org
Fri Aug 13 17:18:36 UTC 2010


Attached is a patch that that adds an abstraction to commonly used 
functionality in the code base - to iterate raw hashes.

It is implemented as a macros:
1st macro adds syntax like:

parrot_hash_iterate(hash, <some_code_here>);

in the code, there is defined _bucket variable;

for example

parrot_hash_iterate(hash, _bucket->value += 1);

The code could be of arbitrary size;

the second macro "parrot_hash_iterator" is modeled after 
hashiterator.pmc. For example usage, look there.

I have replaced all manual iterations of hashes with this macros. This 
will give us a flexibility to change hash internals only changing 2 
files - hash.c and hash.h whithout breaking unknown places that poke 
with hash internals.

As macros, they are text substitution, so there will be no performace hit.

I am open to comments and suggestions

luben


-------------- next part --------------
A non-text attachment was scrubbed...
Name: iter.patch
Type: text/x-patch
Size: 12733 bytes
Desc: not available
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20100813/759c7adb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: luben.vcf
Type: text/x-vcard
Size: 178 bytes
Desc: not available
URL: <http://lists.parrot.org/pipermail/parrot-dev/attachments/20100813/759c7adb/attachment.vcf>


More information about the parrot-dev mailing list