Mercurial > hg > xemacs-beta
changeset 5752:70a3f4ff8da8
Improve coding style, variable names, data.c, sequence.c
src/ChangeLog addition:
2013-08-05 Aidan Kehoe <kehoea@parhasard.net>
* data.c:
* data.c (Fcar):
* data.c (Fcdr):
* data.c (Fmake_weak_box):
* data.c (Fweak_box_ref):
* data.c (init_marking_ephemerons):
* data.c (continue_marking_ephemerons):
* data.c (finish_marking_ephemerons):
* data.c (prune_ephemerons):
* data.c (zap_finalize_list):
* data.c (ephemeron_equal):
* data.c (ephemeron_hash):
* data.c (Fmake_ephemeron):
* data.c (Fephemeron_ref):
* data.c (Fephemeronp):
* sequence.c:
* sequence.c (Fcopy_tree):
* sequence.c (Freplace):
Improve coding style here; #'car and #'cdr accept lists, not just
cons cells, update their argument names to reflect that.
Follow coding conventions in the weak box and ephemeron code.
Don't needlessly abbreviate in copy-tree, use argument names from
Common Lisp in #'merge and #'replace.
Document ALIST better in #'nsublis, #'sublis.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 05 Aug 2013 17:20:16 +0100 |
parents | 2b8edd304c2b |
children | dbd8305e13cb |
files | src/ChangeLog src/data.c src/sequence.c |
diffstat | 3 files changed, 78 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Mon Aug 05 13:34:27 2013 +0100 +++ b/src/ChangeLog Mon Aug 05 17:20:16 2013 +0100 @@ -1,3 +1,30 @@ +2013-08-05 Aidan Kehoe <kehoea@parhasard.net> + + * data.c: + * data.c (Fcar): + * data.c (Fcdr): + * data.c (Fmake_weak_box): + * data.c (Fweak_box_ref): + * data.c (init_marking_ephemerons): + * data.c (continue_marking_ephemerons): + * data.c (finish_marking_ephemerons): + * data.c (prune_ephemerons): + * data.c (zap_finalize_list): + * data.c (ephemeron_equal): + * data.c (ephemeron_hash): + * data.c (Fmake_ephemeron): + * data.c (Fephemeron_ref): + * data.c (Fephemeronp): + * sequence.c: + * sequence.c (Fcopy_tree): + * sequence.c (Freplace): + Improve coding style here; #'car and #'cdr accept lists, not just + cons cells, update their argument names to reflect that. + Follow coding conventions in the weak box and ephemeron code. + Don't needlessly abbreviate in copy-tree, use argument names from + Common Lisp in #'merge and #'replace. + Document ALIST better in #'nsublis, #'sublis. + 2013-06-17 Jerry James <james@xemacs.org> * Makefile.in.in: Support bignums with MPIR.
--- a/src/data.c Mon Aug 05 13:34:27 2013 +0100 +++ b/src/data.c Mon Aug 05 17:20:16 2013 +0100 @@ -572,21 +572,21 @@ /* Extract and set components of lists */ DEFUN ("car", Fcar, 1, 1, 0, /* -Return the car of CONS. If CONS is nil, return nil. +Return the car of LIST. If LIST is nil, return nil. The car of a list or a dotted pair is its first element. -Error if CONS is not nil and not a cons cell. See also `car-safe'. +Error if LIST is not nil and not a cons cell. See also `car-safe'. */ - (cons)) + (list)) { while (1) { - if (CONSP (cons)) - return XCAR (cons); - else if (NILP (cons)) + if (CONSP (list)) + return XCAR (list); + else if (NILP (list)) return Qnil; else - cons = wrong_type_argument (Qlistp, cons); + list = wrong_type_argument (Qlistp, list); } } @@ -599,22 +599,22 @@ } DEFUN ("cdr", Fcdr, 1, 1, 0, /* -Return the cdr of CONS. If CONS is nil, return nil. +Return the cdr of LIST. If LIST is nil, return nil. The cdr of a list is the list without its first element. The cdr of a dotted pair (A . B) is the second element, B. Error if arg is not nil and not a cons cell. See also `cdr-safe'. */ - (cons)) + (list)) { while (1) { - if (CONSP (cons)) - return XCDR (cons); - else if (NILP (cons)) + if (CONSP (list)) + return XCDR (list); + else if (NILP (list)) return Qnil; else - cons = wrong_type_argument (Qlistp, cons); + list = wrong_type_argument (Qlistp, list); } } @@ -3121,16 +3121,16 @@ */ (value)) { - return make_weak_box(value); + return make_weak_box (value); } DEFUN ("weak-box-ref", Fweak_box_ref, 1, 1, 0, /* Return the contents of weak box WEAK-BOX. If the contents have been GCed, return NIL. */ - (wb)) + (weak_box)) { - return XWEAK_BOX (wb)->value; + return XWEAK_BOX (weak_box)->value; } DEFUN ("weak-box-p", Fweak_boxp, 1, 1, 0, /* @@ -3161,7 +3161,7 @@ static Lisp_Object Vfinalize_list; void -init_marking_ephemerons(void) +init_marking_ephemerons (void) { Vnew_all_ephemerons = Qnil; } @@ -3171,7 +3171,7 @@ * way. */ int -continue_marking_ephemerons(void) +continue_marking_ephemerons (void) { Lisp_Object rest = Vall_ephemerons, next, prev = Qnil; int did_mark = 0; @@ -3217,7 +3217,7 @@ */ int -finish_marking_ephemerons(void) +finish_marking_ephemerons (void) { Lisp_Object rest = Vall_ephemerons, next, prev = Qnil; int did_mark = 0; @@ -3264,13 +3264,13 @@ } void -prune_ephemerons(void) +prune_ephemerons (void) { Vall_ephemerons = Vnew_all_ephemerons; } Lisp_Object -zap_finalize_list(void) +zap_finalize_list (void) { Lisp_Object finalizers = Vfinalize_list; @@ -3306,12 +3306,12 @@ ephemeron_equal (Lisp_Object obj1, Lisp_Object obj2, int depth, int foldcase) { return - internal_equal_0 (XEPHEMERON_REF (obj1), XEPHEMERON_REF(obj2), depth + 1, - foldcase); + internal_equal_0 (XEPHEMERON_REF (obj1), XEPHEMERON_REF (obj2), + depth + 1, foldcase); } static Hashcode -ephemeron_hash(Lisp_Object obj, int depth, Boolint equalp) +ephemeron_hash (Lisp_Object obj, int depth, Boolint equalp) { return internal_hash (XEPHEMERON_REF (obj), depth + 1, equalp); } @@ -3345,11 +3345,11 @@ /* Ephemerons are special cases in the KKCC mark algorithm, so nothing is marked here. */ static const struct memory_description ephemeron_description[] = { - { XD_LISP_OBJECT, offsetof(struct ephemeron, key), + { XD_LISP_OBJECT, offsetof (struct ephemeron, key), 0, { 0 }, XD_FLAG_NO_KKCC }, - { XD_LISP_OBJECT, offsetof(struct ephemeron, cons_chain), + { XD_LISP_OBJECT, offsetof (struct ephemeron, cons_chain), 0, { 0 }, XD_FLAG_NO_KKCC }, - { XD_LISP_OBJECT, offsetof(struct ephemeron, value), + { XD_LISP_OBJECT, offsetof (struct ephemeron, value), 0, { 0 }, XD_FLAG_NO_KKCC }, { XD_END } }; @@ -3372,16 +3372,16 @@ */ (key, value, finalizer)) { - return make_ephemeron(key, value, finalizer); + return make_ephemeron (key, value, finalizer); } DEFUN ("ephemeron-ref", Fephemeron_ref, 1, 1, 0, /* Return the contents of ephemeron EPHEMERON. If the contents have been GCed, return NIL. */ - (eph)) + (ephemeron)) { - return XEPHEMERON_REF (eph); + return XEPHEMERON_REF (ephemeron); } DEFUN ("ephemeron-p", Fephemeronp, 1, 1, 0, /*
--- a/src/sequence.c Mon Aug 05 13:34:27 2013 +0100 +++ b/src/sequence.c Mon Aug 05 17:20:16 2013 +0100 @@ -1161,12 +1161,12 @@ Return a copy of a list and substructures. The argument is copied, and any lists contained within it are copied recursively. Circularities and shared substructures are not preserved. -Second arg VECP causes vectors to be copied, too. Strings and bit vectors -are not copied. +Second arg VECTORP causes vectors to be copied, too. Strings and bit +vectors are not copied. */ - (arg, vecp)) -{ - return safe_copy_tree (arg, vecp, 0); + (arg, vectorp)) +{ + return safe_copy_tree (arg, vectorp, 0); } Lisp_Object @@ -3723,15 +3723,15 @@ } while (0) DEFUN ("merge", Fmerge, 4, MANY, 0, /* -Destructively merge SEQUENCE-ONE and SEQUENCE-TWO, producing a new sequence. +Destructively merge SEQUENCE1 and SEQUENCE2, producing a new sequence. TYPE is the type of sequence to return. PREDICATE is a `less-than' predicate on the elements. Optional keyword argument KEY is a function used to extract an object to be -used for comparison from each element of SEQUENCE-ONE and SEQUENCE-TWO. - -arguments: (TYPE SEQUENCE-ONE SEQUENCE-TWO PREDICATE &key (KEY #'IDENTITY)) +used for comparison from each element of SEQUENCE1 and SEQUENCE2. + +arguments: (TYPE SEQUENCE1 SEQUENCE2 PREDICATE &key (KEY #'IDENTITY)) */ (int nargs, Lisp_Object *args)) { @@ -5270,16 +5270,16 @@ } DEFUN ("replace", Freplace, 2, MANY, 0, /* -Replace the elements of SEQUENCE-ONE with the elements of SEQUENCE-TWO. - -SEQUENCE-ONE is destructively modified, and returned. Its length is not +Replace the elements of SEQUENCE1 with the elements of SEQUENCE2. + +SEQUENCE1 is destructively modified, and returned. Its length is not changed. -Keywords :start1 and :end1 specify a subsequence of SEQUENCE-ONE, and -:start2 and :end2 a subsequence of SEQUENCE-TWO. See `search' for more +Keywords :start1 and :end1 specify a subsequence of SEQUENCE1, and +:start2 and :end2 a subsequence of SEQUENCE2. See `search' for more information. -arguments: (SEQUENCE-ONE SEQUENCE-TWO &key (START1 0) (END1 (length SEQUENCE-ONE)) (START2 0) (END2 (length SEQUENCE-TWO))) +arguments: (SEQUENCE1 SEQUENCE2 &key (START1 0) (END1 (length SEQUENCE1)) (START2 0) (END2 (length SEQUENCE2))) */ (int nargs, Lisp_Object *args)) { @@ -6234,6 +6234,9 @@ Perform substitutions indicated by ALIST in TREE (non-destructively). Return a copy of TREE with all matching elements replaced. +Each dotted pair in ALIST describes a map from an old value (the car) to be +replaced by a new value (the cdr). + See `member*' for the meaning of :test, :test-not and :key. arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT) @@ -6362,6 +6365,9 @@ Perform substitutions indicated by ALIST in TREE (destructively). Any matching element of TREE is changed via a call to `setcar'. +Each dotted pair in ALIST describes a map from an old value (the car) to be +replaced by a new value (the cdr). + See `member*' for the meaning of :test, :test-not and :key. arguments: (ALIST TREE &key (TEST #'eql) (KEY #'identity) TEST-NOT)