unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Emacs-devel@gnu.org
Subject: Re: documentation of integers, fixnums and bignums
Date: Sat, 08 Sep 2018 19:27:24 +0300	[thread overview]
Message-ID: <83pnxorm37.fsf@gnu.org> (raw)
In-Reply-To: <0f632217-27ad-4f54-8ce0-480301fa2a86@cs.ucla.edu> (message from Paul Eggert on Sat, 8 Sep 2018 09:09:03 -0700)

> From: Paul Eggert <eggert@cs.ucla.edu>
> Cc: Emacs Development <Emacs-devel@gnu.org>
> Date: Sat, 8 Sep 2018 09:09:03 -0700
> 
> >  DEFUN ("encode-char", Fencode_char, Sencode_char, 2, 2, 0,
> >         doc: /* Encode the character CH into a code-point of CHARSET.
> > -Return nil if CHARSET doesn't include CH.  */)
> > +Return the encoded code-point, a fixnum if its value is small enough,
> > +otherwise a bignum.
> > +Return nil if CHARSET doesn't support CH.  */)
> 
> As the intent is that Emacs should treat integers transparently, so that 
> ordinary code needn't worry about the difference between bignums and fixnums, it 
> would be better if documentation like this simply says something like "Return 
> the encoded code-point, an integer", as this is more concise.

Sorry, I disagree.  I think it's important for the Lisp programmers to
know what kind of objects they could get as return values.  Maybe in
some distant future we will no longer care about the difference
between fixnums and bignums, but as of now, we still do.

I've left the ELisp manual documentation which says "number" without
these details, but I think at least the doc strings should spell out
these details, for now.

> It's true that the current integer implementation is a bit different, in that eq 
> and = now treat integers differently; but this is a global property that is best 
> documented in the integer section of the Emacs manual. We shouldn't need to add 
> a comment in each function returning an integer in effect saying "watch out! eq 
> and = might act differently on these integers!" as the cost to users of this 
> documentation complication will exceed its benefit in the long run.

I think we should call out the functions that can return bignums
because of this and other peculiarities of bignums.  Otherwise, people
will have hard time writing robust programs that use these APIs.
E.g., it would take an expert in obscure character sets to know that
encode-char could potentially return a value that cannot be
represented as a fixnum.



  reply	other threads:[~2018-09-08 16:27 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-08 16:09 documentation of integers, fixnums and bignums Paul Eggert
2018-09-08 16:27 ` Eli Zaretskii [this message]
2018-09-08 18:15   ` Stefan Monnier
2018-09-08 20:15     ` Paul Eggert
2018-09-08 22:03       ` Stefan Monnier
2018-09-08 23:37         ` Paul Eggert
2018-09-09  2:33           ` Stefan Monnier
2018-09-09  5:40           ` Eli Zaretskii
2018-09-10  0:09             ` Stefan Monnier
2018-09-10  6:43               ` Eli Zaretskii
2018-09-10 12:11                 ` Stefan Monnier
2018-09-10 13:53                   ` Eli Zaretskii
2018-09-09  5:42         ` Eli Zaretskii
2018-09-10  0:12           ` Stefan Monnier
2018-09-08 20:05   ` Paul Eggert
2018-09-08 21:07     ` Eli Zaretskii
2018-09-08 21:58     ` Stefan Monnier
     [not found] <<0f632217-27ad-4f54-8ce0-480301fa2a86@cs.ucla.edu>
     [not found] ` <<83pnxorm37.fsf@gnu.org>
2018-09-09  1:43   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83pnxorm37.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=Emacs-devel@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).