From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: New library num-base-converters
Date: Tue, 15 Aug 2017 09:40:04 -0400 [thread overview]
Message-ID: <87mv71lzkb.fsf@lifelogs.com> (raw)
In-Reply-To: jwvbmnhjmi1.fsf-monnier+gmane.emacs.devel@gnu.org
On Tue, 15 Aug 2017 03:55:19 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> +(defun nbc-number-base-converter (num base-in base-out)
>> + "Translate NUM, a string representing an integer, to a different base.
>> +BASE-IN, an integer, is the basis of the input NUM.
>> +BASE-OUT, an integer, is the basis to display NUM."
SM> Having a string as both input and output is a bad API, I think.
It's OK for a parser :)
SM> All one needs is basically to add a `base` arg to number-to-string
SM> (there's already one for string-to-number).
I think that's a good improvement as well, especially if it works for
larger bases and errors out if the base is out of range.
On Tue, 15 Aug 2017 18:49:45 +0900 (JST) Tino Calancha <tino.calancha@gmail.com> wrote:
TC> It's better API than not having API at all; it provides me the flexibility
TC> to handle input as '0xff', '#xff' or 'ff'. Not that bad.
So one approach is to write your library so it parses and converts in
one shot, as it does today. This limits its utility and reusability.
The other approach is to follow Stefan's suggestion to improve
`number-to-string' and `string-to-number' in the core, and then to add
to your library a dedicated parser that can accept all the possible
inputs you want. So your library would be that parser plus glue to
`number-to-string' and `string-to-number'. Maybe also a fallback for
backwards compatibility if the core `number-to-string' and
`string-to-number' are less capable. I think that solution would benefit
Emacs developers and users the most, long-term.
Ted
prev parent reply other threads:[~2017-08-15 13:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-14 17:26 New library num-base-converters Tino Calancha
2017-08-14 17:48 ` Ted Zlatanov
2017-08-15 2:11 ` raman
2017-08-15 2:50 ` Tino Calancha
2017-08-15 5:25 ` Drew Adams
2017-08-15 6:35 ` Tino Calancha
2017-08-15 7:55 ` Stefan Monnier
2017-08-15 9:49 ` Tino Calancha
2017-08-15 15:24 ` Stefan Monnier
2017-08-15 13:40 ` Ted Zlatanov [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mv71lzkb.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.