emacs-devel
[Top][All Lists]
Advanced

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

Re: evaluating numbers


From: Stefan Monnier
Subject: Re: evaluating numbers
Date: Sat, 09 Nov 2019 23:47:34 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>>>> 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?

I'd encourage you try and write such a hack.  Then consider whether (and
how) it should try and handle cases such as

    (let ((x 345)) (decode-char 'emacs x))
or
    (1+ (decode-char 'emacs 345))
or
    (funcall #'decode-char 'emacs 345)
or
    (aref s 3)

[ 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 ]

I think you're just beginning to discover that XEmacs's decision to have
characters as a built-in type, separate from integers, does occasionally
offer some benefits ;-)


        Stefan




reply via email to

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