bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9653: 24.0.50; `ucs-names' - Why all of the ("" . XXX) entries?


From: Kenichi Handa
Subject: bug#9653: 24.0.50; `ucs-names' - Why all of the ("" . XXX) entries?
Date: Wed, 05 Oct 2011 17:59:06 +0900

You wrote:

> >> - even less so when it talks about internal APIs rather than about
> >> externally-visible behavior.
> > I think that UCD is talking about external visible behaviour.
> 
> If so, it doesn't apply to the behavior of (get-char-code-property CHAR
> 'name) which is an internal detail.

I think what get-char-code-proeprty returns belongs to an
external API, and currently I put this docstring to `name'
property.

"Unicode character name.
Property value is a string."

So, when one wants to know a Unicode name of a character, he
can call get-char-code-proeprty and it should return "".

> >> - "null string" can mean nil just as well as it can mean "".
> > But, as I wrote, nil usually means
> > no-value/not-specified/unassigned/unknown, which is
> > different from the explicit "".
> 
> Indeed, and that's why I prefer nil: a char's name should be pretty much
> unique and descriptive, so "" really isn't a char name, it just means
> "this char doesn't have a name" and in Elisp we usually represent this
> with nil.

Perhaps we are requesting two functionalities to
get-char-code-property.  One is to return the specific name
of a character or nil if it doesn't have such a name, the
other is to just return a name that Unicode defines for a
character.  As there's just one function at the moment, we
should find which functionality is more useful.

> >> So was there some other motivation (e.g. simpler implementation?
> > No.
> 
> Then please revert it to using nil.

So, your opinion is that the former functionality is more
useful, right?

Then, ok, I'll change it back, and, change the above
docstring accordingly.

> >> Simpler code somewhere else?)?
> > Yes, hypothetically.  You can safely write, for instance,
> >   (search-forward (get-char-code-property CHAR 'name) ...)
> > or
> >   (insert (get-char-code-property CHAR 'name) ...)
> > without checking the return value.
> 
> I doubt there will ever be code that can do the above because the ""
> case will need special treatment.
> 
> So we end comparing things like
> 
>   (insert (or (get-char-code-property CHAR 'name) "<Unnamed>"))
> with
>   (insert (let ((name (get-char-code-property CHAR 'name)))
>             (if (equal name "") "<Unnamed>" name)))
> 
> where nil is clearly a more convenient choice.

I'll repeat that when one want to know what Unicode says
about the name of a character, the answer is "", not
"<Unnamed>".

> >> If not (i.e. all things being equal) I'd prefer to use nil which is
> >> ever so slightly closer to usual Elisp practice,
> > Really?  I've thought nil and "" are rather different object in Elisp.
> 
> Of course they are, nil usually means "not found" or something like
> that, and I think it suits this case perfectly.

I'm not sure because there are multiple use-cases of
get-char-code-property, and nil is better only in some of
them.  But, it's just "I'm not sure".  If you are sure, as I
wrote above, I'll change it back.

---
Kenichi Handa
handa@m17n.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]