
#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: -------------------------------------+------------------------------------- Description changed by hvr: Old description:
Currently, Haskell98/2010 support base-10, base-8 (via `0[oO]`-prefix) and base-16 (via `0[xX]`-prefix) integer literals.
I hereby propose to add conditional support for base-2 integers via a `0[bB]`-prefix, controlled via a new `-XBinaryLiterals` language extension flag/pragma. The change to the lexer is trivial (see attached patch), however I'm stuck on the lexer using a 32-bit feature-mask, of which all 32bits are already taken, and I'd need a 33th bit for the `BinaryLiteralsBit` flag.
New description: Haskell2010 supports - base-10 (prefix-less), - base-8 (via `0[oO]`-prefix), and - base-16 (via `0[xX]`-prefix) integer literals. I hereby propose to add conditional support for base-2 integers literals via a `0[bB]`-prefix, disabled by default, and controllable via a new `{-# LANGUAGE BinaryLiterals #-}` language extension flag/pragma. The use of a `0b` prefix for indicating binary literals is known from popular programming languages such as Python, Ruby, and Java. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9224#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler