[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A question about category name in ELisp
From: |
Eli Zaretskii |
Subject: |
Re: A question about category name in ELisp |
Date: |
Sat, 05 Oct 2013 15:41:19 +0300 |
> Date: Sat, 5 Oct 2013 18:43:27 +0800
> From: Xue Fuqiao <xfq.free@gmail.com>
>
> I have a question about category and category table. In (info
> "(elisp) Categories"):
>
> Each category has a name, which is an ASCII printing character in
> the range ‘ ’ to ‘~’. You specify the name of a category when you
> define it with ‘define-category’.
> The category table is actually a char-table (*note Char-Tables::).
> The element of the category table at index C is a "category set"—a
> bool-vector—that indicates which categories character C belongs to.
> In this category set, if the element at index CAT is ‘t’, that means
> category CAT is a member of the set, and that character C belongs to
> category CAT.
>
> >From the second paragraph, my impression about a category table is
> something like this:
>
> | | a | - | . | " |
> |-----+-----+-----+-----+-----|
> | bv1 | bv2 | bv3 | bv4 | bv5 |
>
> (The first row contains the indices of the char-table (i.e., the
> "index C" above), and the second row contains the elements at index
> C1, C2, ... (i.e., it's a category set, which is a bool-vector.))
>
> As with all arrays, bool-vector indices start from 0, so CAT should be
> an integer. But according to my understanding, CAT is a category
> name, which should be an ASCII printing character (instead of just an
> integer, from the first paragraph). Why? Am I missing something?
You need to read about char-table, your assumption about its structure
is wrong. In particular, a char-table is not a flat array, and it is
indexed by characters, not by zero-based integers.