What is a type error?

Rob Warnock rpw3 at rpw3.org
Mon Jul 17 04:39:44 EDT 2006


Joachim Durchholz  <jo at durchholz.org> wrote:
+---------------
| INSERT cannot be expressed in terms of assignment. INSERT creates a new 
| record; there's no way that assignment in a language like C can create a 
| new data structure!  The same goes for DELETE.
+---------------

Well, what about "malloc()" & "free()"? I mean, if your
"database" is a simple linked list, then INSERT is just:

    ROW *p = malloc(sizeof *p);
    p->field1 = value1;
    p->field2 = value2;
    ...
    p->fieldN = valueN;
    database = cons(p, database);		/* Common Lisp's CONS */

and DELETE is just:

    ROW *p = find_if(predicate_function, database); /* CL's FIND-IF */
    database = delete(p, database);		/* CL's DELETE */
    free(p);

[There are single-pass methods, of course, but...]


-Rob

-----
Rob Warnock			<rpw3 at rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607




More information about the Python-list mailing list