Re: linked list rewrite

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Neil Conway <neilc(at)samurai(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: linked list rewrite
Date: 2004-03-23 21:59:45
Message-ID: 6870.1080079185@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Finner 2004-03-23 22:13:54 Re: partial VACUUM FULL
Previous Message Bruce Momjian 2004-03-23 21:37:39 Re: Ident authentication is not supported on local connections

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-03-23 22:07:35 Re: dollar quoting and pg_dump
Previous Message Bruce Momjian 2004-03-23 21:34:29 Re: [COMMITTERS] pgsql-server/ oc/src/sgml/ref/alter_table.sgml