Mercurial > hg > xemacs-beta
comparison src/data.c @ 3343:29234c1a76c7
[xemacs-hg @ 2006-04-16 15:54:16 by aidan]
Docstring improvements for basic Lisp functions, CL.
author | aidan |
---|---|
date | Sun, 16 Apr 2006 15:54:21 +0000 |
parents | 1e7cc382eb16 |
children | 721daee0fcd8 |
comparison
equal
deleted
inserted
replaced
3342:9e258fc95550 | 3343:29234c1a76c7 |
---|---|
214 return NILP (object) ? Qt : Qnil; | 214 return NILP (object) ? Qt : Qnil; |
215 } | 215 } |
216 | 216 |
217 DEFUN ("consp", Fconsp, 1, 1, 0, /* | 217 DEFUN ("consp", Fconsp, 1, 1, 0, /* |
218 Return t if OBJECT is a cons cell. `nil' is not a cons cell. | 218 Return t if OBJECT is a cons cell. `nil' is not a cons cell. |
219 | |
220 A cons cell is a Lisp object (an area in memory) comprising two pointers | |
221 called the CAR and the CDR. Each of these pointers can point to any other | |
222 Lisp object. The common Lisp data type, the list, is a specially-structured | |
223 series of cons cells. | |
219 */ | 224 */ |
220 (object)) | 225 (object)) |
221 { | 226 { |
222 return CONSP (object) ? Qt : Qnil; | 227 return CONSP (object) ? Qt : Qnil; |
223 } | 228 } |
230 return CONSP (object) ? Qnil : Qt; | 235 return CONSP (object) ? Qnil : Qt; |
231 } | 236 } |
232 | 237 |
233 DEFUN ("listp", Flistp, 1, 1, 0, /* | 238 DEFUN ("listp", Flistp, 1, 1, 0, /* |
234 Return t if OBJECT is a list. `nil' is a list. | 239 Return t if OBJECT is a list. `nil' is a list. |
240 | |
241 A list is implemented as a series of cons cells structured such that the CDR | |
242 of each cell either points to another cons cell or to `nil', the special | |
243 Lisp value for both Boolean false and the empty list. | |
235 */ | 244 */ |
236 (object)) | 245 (object)) |
237 { | 246 { |
238 return LISTP (object) ? Qt : Qnil; | 247 return LISTP (object) ? Qt : Qnil; |
239 } | 248 } |
254 return TRUE_LIST_P (object) ? Qt : Qnil; | 263 return TRUE_LIST_P (object) ? Qt : Qnil; |
255 } | 264 } |
256 | 265 |
257 DEFUN ("symbolp", Fsymbolp, 1, 1, 0, /* | 266 DEFUN ("symbolp", Fsymbolp, 1, 1, 0, /* |
258 Return t if OBJECT is a symbol. | 267 Return t if OBJECT is a symbol. |
268 | |
269 A symbol is a Lisp object with a name. It can optionally have any and all of | |
270 a value, a property list and an associated function. | |
259 */ | 271 */ |
260 (object)) | 272 (object)) |
261 { | 273 { |
262 return SYMBOLP (object) ? Qt : Qnil; | 274 return SYMBOLP (object) ? Qt : Qnil; |
263 } | 275 } |
598 | 610 |
599 | 611 |
600 /* Extract and set components of lists */ | 612 /* Extract and set components of lists */ |
601 | 613 |
602 DEFUN ("car", Fcar, 1, 1, 0, /* | 614 DEFUN ("car", Fcar, 1, 1, 0, /* |
603 Return the car of LIST. If arg is nil, return nil. | 615 Return the car of CONS. If CONS is nil, return nil. |
604 Error if arg is not nil and not a cons cell. See also `car-safe'. | 616 The car of a list or a dotted pair is its first element. |
605 */ | 617 |
606 (list)) | 618 Error if CONS is not nil and not a cons cell. See also `car-safe'. |
619 */ | |
620 (cons)) | |
607 { | 621 { |
608 while (1) | 622 while (1) |
609 { | 623 { |
610 if (CONSP (list)) | 624 if (CONSP (cons)) |
611 return XCAR (list); | 625 return XCAR (cons); |
612 else if (NILP (list)) | 626 else if (NILP (cons)) |
613 return Qnil; | 627 return Qnil; |
614 else | 628 else |
615 list = wrong_type_argument (Qlistp, list); | 629 cons = wrong_type_argument (Qlistp, cons); |
616 } | 630 } |
617 } | 631 } |
618 | 632 |
619 DEFUN ("car-safe", Fcar_safe, 1, 1, 0, /* | 633 DEFUN ("car-safe", Fcar_safe, 1, 1, 0, /* |
620 Return the car of OBJECT if it is a cons cell, or else nil. | 634 Return the car of OBJECT if it is a cons cell, or else nil. |
623 { | 637 { |
624 return CONSP (object) ? XCAR (object) : Qnil; | 638 return CONSP (object) ? XCAR (object) : Qnil; |
625 } | 639 } |
626 | 640 |
627 DEFUN ("cdr", Fcdr, 1, 1, 0, /* | 641 DEFUN ("cdr", Fcdr, 1, 1, 0, /* |
628 Return the cdr of LIST. If arg is nil, return nil. | 642 Return the cdr of CONS. If CONS is nil, return nil. |
643 The cdr of a list is the list without its first element. The cdr of a | |
644 dotted pair (A . B) is the second element, B. | |
645 | |
629 Error if arg is not nil and not a cons cell. See also `cdr-safe'. | 646 Error if arg is not nil and not a cons cell. See also `cdr-safe'. |
630 */ | 647 */ |
631 (list)) | 648 (cons)) |
632 { | 649 { |
633 while (1) | 650 while (1) |
634 { | 651 { |
635 if (CONSP (list)) | 652 if (CONSP (cons)) |
636 return XCDR (list); | 653 return XCDR (cons); |
637 else if (NILP (list)) | 654 else if (NILP (cons)) |
638 return Qnil; | 655 return Qnil; |
639 else | 656 else |
640 list = wrong_type_argument (Qlistp, list); | 657 cons = wrong_type_argument (Qlistp, cons); |
641 } | 658 } |
642 } | 659 } |
643 | 660 |
644 DEFUN ("cdr-safe", Fcdr_safe, 1, 1, 0, /* | 661 DEFUN ("cdr-safe", Fcdr_safe, 1, 1, 0, /* |
645 Return the cdr of OBJECT if it is a cons cell, else nil. | 662 Return the cdr of OBJECT if it is a cons cell, else nil. |
649 return CONSP (object) ? XCDR (object) : Qnil; | 666 return CONSP (object) ? XCDR (object) : Qnil; |
650 } | 667 } |
651 | 668 |
652 DEFUN ("setcar", Fsetcar, 2, 2, 0, /* | 669 DEFUN ("setcar", Fsetcar, 2, 2, 0, /* |
653 Set the car of CONS-CELL to be NEWCAR. Return NEWCAR. | 670 Set the car of CONS-CELL to be NEWCAR. Return NEWCAR. |
671 The car of a list or a dotted pair is its first element. | |
654 */ | 672 */ |
655 (cons_cell, newcar)) | 673 (cons_cell, newcar)) |
656 { | 674 { |
657 if (!CONSP (cons_cell)) | 675 if (!CONSP (cons_cell)) |
658 cons_cell = wrong_type_argument (Qconsp, cons_cell); | 676 cons_cell = wrong_type_argument (Qconsp, cons_cell); |
661 return newcar; | 679 return newcar; |
662 } | 680 } |
663 | 681 |
664 DEFUN ("setcdr", Fsetcdr, 2, 2, 0, /* | 682 DEFUN ("setcdr", Fsetcdr, 2, 2, 0, /* |
665 Set the cdr of CONS-CELL to be NEWCDR. Return NEWCDR. | 683 Set the cdr of CONS-CELL to be NEWCDR. Return NEWCDR. |
684 The cdr of a list is the list without its first element. The cdr of a | |
685 dotted pair (A . B) is the second element, B. | |
666 */ | 686 */ |
667 (cons_cell, newcdr)) | 687 (cons_cell, newcdr)) |
668 { | 688 { |
669 if (!CONSP (cons_cell)) | 689 if (!CONSP (cons_cell)) |
670 cons_cell = wrong_type_argument (Qconsp, cons_cell); | 690 cons_cell = wrong_type_argument (Qconsp, cons_cell); |
984 ARITHCOMPARE_MANY (==, eql) | 1004 ARITHCOMPARE_MANY (==, eql) |
985 } | 1005 } |
986 | 1006 |
987 DEFUN ("<", Flss, 1, MANY, 0, /* | 1007 DEFUN ("<", Flss, 1, MANY, 0, /* |
988 Return t if the sequence of arguments is monotonically increasing. | 1008 Return t if the sequence of arguments is monotonically increasing. |
989 The arguments may be numbers, characters or markers. | 1009 |
1010 (That is, if there is a second argument, it must be numerically greater than | |
1011 the first. If there is a third, it must be numerically greater than the | |
1012 second, and so on.) At least one argument is required. | |
1013 | |
1014 The arguments may be numbers, characters or markers. | |
990 */ | 1015 */ |
991 (int nargs, Lisp_Object *args)) | 1016 (int nargs, Lisp_Object *args)) |
992 { | 1017 { |
993 ARITHCOMPARE_MANY (<, lt) | 1018 ARITHCOMPARE_MANY (<, lt) |
994 } | 1019 } |
995 | 1020 |
996 DEFUN (">", Fgtr, 1, MANY, 0, /* | 1021 DEFUN (">", Fgtr, 1, MANY, 0, /* |
997 Return t if the sequence of arguments is monotonically decreasing. | 1022 Return t if the sequence of arguments is monotonically decreasing. |
1023 | |
1024 (That is, if there is a second argument, it must be numerically less than | |
1025 the first. If there is a third, it must be numerically less than the | |
1026 second, and so forth.) At least one argument is required. | |
1027 | |
998 The arguments may be numbers, characters or markers. | 1028 The arguments may be numbers, characters or markers. |
999 */ | 1029 */ |
1000 (int nargs, Lisp_Object *args)) | 1030 (int nargs, Lisp_Object *args)) |
1001 { | 1031 { |
1002 ARITHCOMPARE_MANY (>, gt) | 1032 ARITHCOMPARE_MANY (>, gt) |