emacs-devel
[Top][All Lists]
Advanced

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

Re: Elisp / C inconsistency for reading "1."


From: Simon Leinen
Subject: Re: Elisp / C inconsistency for reading "1."
Date: Sat, 15 Mar 2014 19:39:43 +0100

On Sat, Mar 15, 2014 at 5:21 PM, Wolfgang Jenkner <address@hidden> wrote:
But please don't base your opinion on a wrong assumption about Common
Lisp, see [1],

        Integers can be written as a sequence of digits [...]
        optionally followed by a decimal point;

Thanks for the reminder!

In case anyone wonders why Common Lisp does it this way: CL has *READ-BASE*, which allows integers to be parsed and unparsed in bases other than decimal.  I think this came from Maclisp, one of the more important Lisp dialects that CL wanted to unify.  Maclisp defaulted to interpreting digit-sequences as octal(!).

So in Common Lisp, when you want to make sure you're in "decimal" mode,
    (SETQ *READ-BASE* 10.)
makes more sense than just
    (SETQ *READ-BASE* 10)
and reads better than e.g.
    (SETQ *READ-BASE* (+ 1 1 1 1 1 1 1 1 1 1))

Sorry for the digression.  As for how Emacs should interpret numbers with a trailing dot: If we want to keep Emacs Lisp aligned with Common Lisp, then we should continue to treat them as decimal integers, and live with the fact that users coming from other languages may have to learn to type "1.0" instead of "1." when they want floats.  Personally I don't have a strong opinion, although I have a slight preference to value CL compatibility higher than convenience for non-native Lisp speakers in this case.  "1." just doesn't look real float'y to me.
-- 
Simon.

reply via email to

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