Next: , Previous: Editing Types, Up: Lisp Data Types   [Contents][Index]


2.5 ·¿½Ò¸ì

Emacs Lisp¥¤¥ó¥¿¡¼¥×¥ê¥¿¼«¿È¤Ï¡¢´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤È¤­¤ËÅϤ¹¼Â°ú¿ô¤Î ·¿¸¡ºº¤ò¹Ô¤¤¤Þ¤»¤ó¡£ ¤½¤¦¤Ç¤­¤Ê¤¤¤Î¤Ï¡¢Â¾¤Î¥×¥í¥°¥é¥à¸À¸ì¤¬¹Ô¤¦¤è¤¦¤Ë¤Ï¡¢ Lisp¤Î´Ø¿ô¤Î°ú¿ô¤Ë¤Ï¥Ç¡¼¥¿·¿¤ÎÀë¸À¤¬¤Ê¤¤¤«¤é¤Ç¤¹¡£ ¤·¤¿¤¬¤Ã¤Æ¡¢³Æ¼Â°ú¿ô¤¬¤½¤Î´Ø¿ô¤Ç°·¤¨¤ë·¿¤Ë°¤¹¤ë¤«¤É¤¦¤«¤ò¸¡ºº¤¹¤ë¤Î¤Ï¡¢ ³Æ´Ø¿ô¤ÎÀÕǤ¤Ç¤¹¡£

¤¹¤Ù¤Æ¤ÎÁȤ߹þ¤ß´Ø¿ô¤Ï¡¢É¬ÍפʤȤ­¤Ë¤Ï¼Â°ú¿ô¤Î·¿¸¡ºº¤ò¹Ô¤¤¡¢ °ú¿ô¤¬¸í¤Ã¤¿·¿¤Ç¤¢¤ì¤Ð¡¢¥¨¥é¡¼wrong-type-argument¤òÄÌÃΤ·¤Þ¤¹¡£ ¤¿¤È¤¨¤Ð¡¢+¤Ë°·¤¨¤Ê¤¤°ú¿ô¤òÅϤ¹¤È¡¢¤Ä¤®¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£

(+ 2 'a)
     error→ Wrong type argument: number-or-marker-p, a

ÆÉ¼Ô¤Î¥×¥í¥°¥é¥à¤Ç¡¢°Û¤Ê¤ë·¿¤ò°Û¤Ê¤ë¤è¤¦¤Ë°·¤¤¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢ ÌÀ¼¨Åª¤Ë·¿¸¡ºº¤ò¹Ô¤¦É¬Íפ¬¤¢¤ê¤Þ¤¹¡£ ¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤ò¸¡ºº¤¹¤ë¤â¤Ã¤È¤â°ìÈÌŪ¤ÊÊýË¡¤Ï¡¢ ·¿½Ò¸ì¡Êtype predicate¡Ë´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¤¹¡£ Emacs¤Ë¤Ï¡¢³Æ·¿¤´¤È¤Ë·¿½Ò¸ì¤¬¤¢¤ê¡¢ ·¿¤òÁȤ߹ç¤ï¤»¤¿¤â¤Î¤ËÂФ¹¤ë½Ò¸ì¤â¤¢¤ê¤Þ¤¹¡£

·¿½Ò¸ì´Ø¿ô¤Ï1¤Ä¤Î°ú¿ô¤ò¼è¤ê¤Þ¤¹¡£ °ú¿ô¤¬Å¬Àڤʷ¿¤Ë°¤·¤Æ¤¤¤ì¤Ðt¤òÊÖ¤·¡¢ ¤µ¤â¤Ê¤±¤ì¤Ðnil¤òÊÖ¤·¤Þ¤¹¡£ ½Ò¸ì´Ø¿ô¤Ë´Ø¤¹¤ëLisp°ìÈ̤δ·½¬¤Ë½¾¤Ã¤Æ¡¢ ¤Û¤È¤ó¤É¤Î·¿½Ò¸ì¤Î̾Á°¤Ï‘p’¤Ç½ª¤ê¤Þ¤¹¡£

°Ê²¼¤Ï¡¢¥ê¥¹¥È¤Î¸¡ºº¤Ë½Ò¸ìlistp¤ò»È¤¤¡¢ ¥·¥ó¥Ü¥ë¤Î¸¡ºº¤Ë½Ò¸ìsymbolp¤ò»È¤¦Îã¤Ç¤¹¡£

(defun add-on (x)
  (cond ((symbolp x)
         ;; X¤¬¥·¥ó¥Ü¥ë¤Ê¤é¤Ð¡¢¤½¤ì¤òLIST¤Ë²Ã¤¨¤ë
         (setq list (cons x list)))
        ((listp x)
         ;; X¤¬¥ê¥¹¥È¤Ê¤é¤Ð¡¢¤½¤ÎÍ×ÁǤòLIST¤ËÄɲ乤ë
         (setq list (append x list)))
        (t
         ;; ¥·¥ó¥Ü¥ë¤È¥ê¥¹¥È¤À¤±¤ò°·¤¦
         (error "Invalid argument %s in add-on" x))))

ÄêµÁºÑ¤ß¤Î·¿½Ò¸ì¤ò¡¢¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È½ç¤Ë¡¢»²¾ÈÀè¤òÊ»µ­¤·¤Æ¤¢¤²¤Æ¤ª¤­¤Þ¤¹¡£

atom

see atom¡£

arrayp

see arrayp¡£

bool-vector-p

see bool-vector-p¡£

bufferp

see bufferp¡£

byte-code-function-p

see byte-code-function-p¡£

case-table-p

see case-table-p¡£

char-or-string-p

see char-or-string-p¡£

char-table-p

see char-table-p¡£

commandp

see commandp¡£

consp

see consp¡£

display-table-p

see display-table-p¡£

floatp

see floatp¡£

frame-configuration-p

see frame-configuration-p¡£

frame-live-p

see frame-live-p¡£

framep

see framep¡£

functionp

see functionp¡£

integer-or-marker-p

see integer-or-marker-p¡£

integerp

see integerp¡£

keymapp

see keymapp¡£

listp

see listp¡£

markerp

see markerp¡£

wholenump

see wholenump¡£

nlistp

see nlistp¡£

numberp

see numberp¡£

number-or-marker-p

see number-or-marker-p¡£

overlayp

see overlayp¡£

processp

see processp¡£

sequencep

see sequencep¡£

stringp

see stringp¡£

subrp

see subrp¡£

symbolp

see symbolp¡£

syntax-table-p

see syntax-table-p¡£

user-variable-p

see user-variable-p¡£

vectorp

see vectorp¡£

window-configuration-p

see window-configuration-p¡£

window-live-p

see window-live-p¡£

windowp

see windowp¡£

¥ª¥Ö¥¸¥§¥¯¥È¤Î·¿¤òÄ´¤Ù¤ë¤â¤Ã¤È¤â°ìÈÌŪ¤ÊÊýË¡¤Ï¡¢ ´Ø¿ôtype-of¤ò¸Æ¤Ó½Ð¤¹¤³¤È¤Ç¤¹¡£ ³Æ¥ª¥Ö¥¸¥§¥¯¥È¤Ï¤¿¤Ã¤¿1¤Ä¤Î´ðËÜ·¿¤Ë°¤¹¤ë¤³¤È¤ò»×¤¤½Ð¤·¤Æ¤¯¤À¤µ¤¤¡£ type-of¤Ï¤É¤Î1¤Ä¤«¤ò¶µ¤¨¤Æ¤¯¤ì¤Þ¤¹¡Êsee Lisp Data Types¡Ë¡£ ¤·¤«¤·¡¢type-of¤Ï¡¢´ðËÜ·¿°Ê³°¤Ë¤Ä¤¤¤Æ¤Ï¤Ê¤Ë¤âÃΤê¤Þ¤»¤ó¡£ ¿¤¯¤Î¾ì¹ç¡¢type-of¤è¤ê·¿½Ò¸ì¤ò»È¤¦¤Û¤¦¤¬ÊØÍø¤Ç¤·¤ç¤¦¡£

Function: type-of object

¤³¤Î´Ø¿ô¤Ï¡¢object¤Î´ðËÜ·¿¤ò¼¨¤¹¥·¥ó¥Ü¥ë¤òÊÖ¤¹¡£ ¤½¤ÎÃͤϡ¢ symbol¡¢ integer¡¢float¡¢string¡¢cons¡¢vector¡¢ char-table¡¢bool-vector¡¢subr¡¢ compiled-function¡¢marker¡¢overlay¡¢window¡¢ buffer¡¢frame¡¢process¡¢window-configuration¤Î ¥·¥ó¥Ü¥ë¤Î¤¦¤Á¤Î1¤Ä¡£

(type-of 1)
     ⇒ integer
(type-of 'nil)
     ⇒ symbol
(type-of '())    ; ()¤Ïnil
     ⇒ symbol
(type-of '(x))
     ⇒ cons

Next: , Previous: Editing Types, Up: Lisp Data Types   [Contents][Index]