[Top][All Lists]

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

Re: evaluating numbers

From: Jean-Christophe Helary
Subject: Re: evaluating numbers
Date: Thu, 14 Nov 2019 08:02:09 +0900

> On Nov 10, 2019, at 13:47, Stefan Monnier <address@hidden> wrote:
>>>>> Characters are just integers in Emacs.
>>>> I know that. You're not really answering the above question. When people
>>>> expect a character to be returned, they expect a character and not
>>>> a code point.
>>> Emacs can't know what the user expects.
>> Developers can know.
>>>> How useful is:
>>>> (decode-char 'emacs 345)
>>>> 345 (#o531, #x159)
>>> And the code that displays "345 (#o531, #x159)" doesn't know that this
>>> 345 is coming out of a function which is expected to return characters.
>> Considering the documentation of decode-char ("returns a character"), that's
>> either an implementation error or a documentation error...
> So you're suggesting that the eval-expression function should look at
> the `car` of the expression that it evaluated, then fetch its docstring
> and see if it claims to return a character?

No. I'm suggesting that the developer who wrote that code and that 
documentation is creating expectations by using the word "character" and thus 
could have implemented the function so that it returns a "character", or a 
"glyph" (which are synonymous) and not only its code point. That's what I mean 
when I write "Developers can know" vs your "Emacs can't know".

> [ Side note: I'm the guy who wrote the code that displays those ?<char>
> thingies, and I'm a great fan of them (and I remove the
> eval-expression-print-maximum-character limit).  But I'll also note
> that if you want to see the char, you can simply wrap your expression
> inside a `string` call, as in M-: (string (decode-char 'emacs 345)) RET ]

As I replied to Eli on the 10th:

> For "discoverability" (or "cognitive gap reduction") purposes, I'd rather 
> have something like
> 1114111 (#o4177777, #x10ffff, t)
> 232 (#o350, #xe8, t)
> or something similar where t is the value of characterp for that integer when 
> the integer is above the value of eval-expression-print-maximum-character.
> That way I *know* when an integer is a character and when it is not. And I 
> can find ways to look for it separately.
> Would that break things ?

Would that break things ?

Jean-Christophe Helary
http://mac4translators.blogspot.com @brandelune

reply via email to

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