unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6891: `string-to-number' doesn't recognize `#'' read syntax
@ 2010-08-21  0:01 MON KEY
  2019-06-26 11:37 ` Stefan Kangas
  0 siblings, 1 reply; 4+ messages in thread
From: MON KEY @ 2010-08-21  0:01 UTC (permalink / raw)
  To: 6891

`string-to-number' takes an optional arg BASE but doesn't recognize lisp `#'
read syntax for binary, octal, hex, and radix, e.g.  `#o', `#b', `#x', and
`#<RADIX>r'. It should, these _are_ the respective read syntax for BASE.
For good measure it should also recognize the string output from
`format's `#' flag for octal and hex e.g `0x' for hex and `0' for octal.

The proposed behaviour should not pose a lisp dialect compatiblility problem as
Emacs lisp does not attempt to follow the Common Lisp spec, does not maintain a
duplicate for CL's `parse-integer' procedure and does not take a bounding START
END arg, but _does_ parse floats so it shouldn't be restricted by that specs
constraints w/re the `#' radix read syntax e.g:

,----
| `parse-integer' does not recognize the syntactic radix-specifier
| prefixes `#O', `#B', `#X', and `#nR', nor does it recognize a trailing
| decimal point.
`----

Besides, `string-to-number' already has a BASE argument, the C code already
strips whitespace, discards "junk", and exhibits a willingness to interpolate
sign in sometimes odd ways, so a little more DWIM can't hurt.

Current `string-to-number' DWIMness:
string-to-number "   -3777777777" 8) ;=> 536870911
(string-to-number "   -3777777777.007" 8) ;=> 536870911
(string-to-number "   -3777777777mmm#" 8) ;=> 536870911
(string-to-number "+   -3777777777mmm#" 8) ;=> 0

Following illustrates the additioanl DWIMing desired:

#o
(string-to-number "#o3777777777" 8) ;=> 536870911

#b
(string-to-number "#b11111111111111111111111111111" 2) ;=> 536870911

#x
(string-to-number "#x1fffffff" 16) ;=> 536870911

#<RDX>r
(string-to-number "#12r12B969227" 12) ;=> 536870911

0x
(string-to-number "0x1fffffff" 16) ;=> 536870911

0
(string-to-number "03777777777" 8) ;=> 536870911


--
/s_P\





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6891: `string-to-number' doesn't recognize `#'' read syntax
  2010-08-21  0:01 bug#6891: `string-to-number' doesn't recognize `#'' read syntax MON KEY
@ 2019-06-26 11:37 ` Stefan Kangas
  2019-06-26 11:44   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Kangas @ 2019-06-26 11:37 UTC (permalink / raw)
  To: 6891, Lars Ingebrigtsen

This bug was tagged as wontfix three years ago.

Is it desirable to close it too?

Thanks,
Stefan Kangas





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6891: `string-to-number' doesn't recognize `#'' read syntax
  2019-06-26 11:37 ` Stefan Kangas
@ 2019-06-26 11:44   ` Lars Ingebrigtsen
  2019-06-26 15:15     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-26 11:44 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 6891

Stefan Kangas <stefan@marxist.se> writes:

> This bug was tagged as wontfix three years ago.
>
> Is it desirable to close it too?

I think so.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6891: `string-to-number' doesn't recognize `#'' read syntax
  2019-06-26 11:44   ` Lars Ingebrigtsen
@ 2019-06-26 15:15     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2019-06-26 15:15 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: stefan, 6891-done

> From: Lars Ingebrigtsen <larsi@gnus.org>
> Date: Wed, 26 Jun 2019 13:44:41 +0200
> Cc: 6891@debbugs.gnu.org
> 
> Stefan Kangas <stefan@marxist.se> writes:
> 
> > This bug was tagged as wontfix three years ago.
> >
> > Is it desirable to close it too?
> 
> I think so.

Agreed and done.

Thanks.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-26 15:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-21  0:01 bug#6891: `string-to-number' doesn't recognize `#'' read syntax MON KEY
2019-06-26 11:37 ` Stefan Kangas
2019-06-26 11:44   ` Lars Ingebrigtsen
2019-06-26 15:15     ` Eli Zaretskii

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).