Skip to content

Consider support for underscores in numeric literals #173

Open
@niklasl

Description

@niklasl

To aid readability, many programming languages allow underscores in numeric literals for separating groups of digits. A common use is to separate in groups of thousands, such as 42_000_000.

For example, this is supported in Java, Python, Javascript, Rust, Erlang and Racket (see links for details and rationale).

Proposed new productions:

DIGITS    ::=   DIGIT ("_" | DIGIT)*
DIGIT     ::=   [0-9]

Updated productions:

INTEGER   ::=   DIGITS
DECIMAL   ::=   DIGITS? '.' DIGITS
DOUBLE    ::=   DIGITS '.' DIGITS? EXPONENT | '.' DIGITS EXPONENT | DIGITS EXPONENT

Example use:

SELECT * { ?s ?p ?o } LIMIT 1_000 OFFSET 20_000

Note that this would purely be syntactic sugar.

(Personally, I've only missed this feature in SPARQL when using LIMIT and/or OFFSET. But it may be nice to define this similarly for Turtle/TriG.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec:enhancementChange to enhance the spec without affecting conformance (class 2) –see also spec:editorialspec:substantiveChange in the spec affecting its normative content (class 3) –see also spec:bug, spec:new-feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions