Bruce Momjian <[EMAIL PROTECTED]> writes:
> What does the 'n' stand for in ncons?  I also felt that lcons
> (construct) and nconc(concat) were too similarly named.

I think nconc is a direct copy from the Lisp original; whatever its
origins are, they're back in Lisp prehistory.  I don't mind renaming
that one ;-)

Let's see ... fleshing out this idea a bit, here's a rundown of all the
symbols in pg_list.h and suggested new names:

ListCell accessors:

lfirst          no change
lfirsti         lfirst_int
lfirsto         lfirst_oid
lnext           no change
foreach         no change

List accessors:

length          no change

lfirstcell      new function to get first cell, or NULL if none

lfirst          rewrite as lfirst(lfirstcell()) when applied to a List

lsecond, lthird, lfourth        not clear if worth keeping

llastnode       llastcell

llast           Perhaps rewrite as lfirst(llastcell()) instead of keeping

makeListN       list_makeN or possibly list_make_N
makeListiN      list_makeN_int or list_make_N_int
makeListoN      list_makeN_oid or list_make_N_oid

lcons           no change
lconsi          lcons_int
lconso          lcons_oid

lappend         no change
lappendi        lappend_int
lappendo        lappend_oid

nconc           list_concat
We might also need a function to attach some bare ListCells to a List

nth             list_nth
                list_nth_int
                list_nth_oid
Should add list_nth_int, list_nth_oid, even though there are no
corresponding functions at the moment

member          list_member
ptrMember       list_member_ptr
intMember       list_member_int
oidMember       list_member_oid

LispRemove      list_remove
lremove         list_remove_ptr
lremovei        list_remove_int
                list_remove_oid         add, though not currently used

ltruncate       list_truncate

set_union       list_union
set_ptrUnion    list_union_ptr
                list_union_int          not currently used
set_uniono      list_union_oid

set_difference  list_difference
set_ptrDifference  list_difference_ptr
                list_difference_int     not currently used
set_differenceo list_difference_oid

equali and equalo become just calls on equal()

freeList        list_free  (frees only List, not pointed-to objects)

listCopy        list_copy  (shallow copy of List only)

A couple of notes here: I propose using the suffix "_ptr" for operations
that use pointer equality rather than equal().  Neil proposed "_simple"
but that seems less than clear to me --- which one is "simple" and which
isn't?  Also, for the "set" operations I have just "list_union" etc
where Neil proposed "list_set_union".

Neil proposed inventing "list_deep_copy" which as far as I can see is
entirely redundant with copyObject.  Similarly I can't see any value in
list_equal when equal() will do the trick.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to