Hi!

Recently, I've been playing around with pg_lists and realize how annoying
(maybe, I was a bit tired) some stuff related to the lists.
For an example, see this code
List     *l1 = list_make4(1, 2, 3, 4),
         *l2 = list_make4(5, 6, 7, 8),
         *l3 = list_make4(9, 0, 1, 2);
ListCell *lc1, *lc2, *lc3;

forthree(lc1, l1, lc2, l2, lc3, l3) {
...
}

list_free(l1);
list_free(l2);
list_free(l3);

There are several questions:
1) Why do I need to specify the number of elements in the list in the
function name?
    Compiler already knew how much arguments do I use.
2) Why I have to call free for every list? I don't know how to call it
right, for now I call it vectorization.
    Why not to use simple wrapper to "vectorize" function args?

So, my proposal is:
1) Add a simple macro to "vectorize" functions.
2) Use this macro to "vectorize" list_free and list_free_deep functions.
3) Use this macro to "vectorize" bms_free function.
4) "Vectorize" list_makeN functions.

For this V1 version, I do not remove all list_makeN calls in order to
reduce diff, but I'll address
this in future, if it will be needed.

In my view, one thing still waiting to be improved if foreach loop. It is
not very handy to have a bunch of
similar calls foreach, forboth, forthree and etc. It will be ideal to have
single foreach interface, but I don't know how
to do it without overall interface of the loop.

Any opinions are very welcome!

-- 
Best regards,
Maxim Orlov.

Attachment: v1-0002-Make-use-of-vectorized-lists_free-and-lists_free_.patch
Description: Binary data

Attachment: v1-0004-vectorize-list_make-functions.patch
Description: Binary data

Attachment: v1-0001-Add-lists_free-and-lists_free_deep.patch
Description: Binary data

Attachment: v1-0003-Make-use-of-vectorized-bmss_free-function.patch
Description: Binary data

Reply via email to