[GHC] #9224: Add support for binary integer literals

GHC ghc-devs at haskell.org
Fri Jun 27 18:58:24 UTC 2014


#9224: Add support for binary integer literals
-------------------------------------+-------------------------------------
        Reporter:  hvr               |            Owner:
            Type:  feature request   |           Status:  new
        Priority:  normal            |        Milestone:  7.10.1
       Component:  Compiler          |          Version:
  (Parser)                           |         Keywords:  literals
      Resolution:                    |     Architecture:  Unknown/Multiple
Operating System:  Unknown/Multiple  |       Difficulty:  Easy (less than 1
 Type of failure:  None/Unknown      |  hour)
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+-------------------------------------

Comment (by Herbert Valerio Riedel <hvr@…>):

 In [changeset:"1c0b5fdc9f2b6ea8166cc565383d4cd20432343c/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="1c0b5fdc9f2b6ea8166cc565383d4cd20432343c"
 Add -XBinaryLiterals language extension (re #9224)

 Haskell2010 supports

 - base-10 (prefix-less),
 - base-8 (via `0[oO]`-prefix), and
 - base-16 (via `0[xX]`-prefix) integer literals.

 This commit adds syntax support for base-2 integer literals via the new
 `0[bB]`
 prefix. The use of a `0b` prefix for indicating binary literals is known
 from popular programming languages such as C++14, Perl, Python, Ruby, and
 Java.

 This syntax extension is disabled by default and can be enabled via the
 new `{-# LANGUAGE BinaryLiterals #-}` pragma and/or the new
 `-XBinaryLiterals`

 This new extensions requires to upgrade the `ExtsBitmap` type from
 `Word` to `Word64` as this adds a 33th flag which is not guaranteed to
 fit into a `Word`.

 Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>

 Differential Revision: https://phabricator.haskell.org/D22
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9224#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list