Skip to content

Proposal: unify float and int as simply number #253

Open
@cueckoo

Description

@cueckoo

Originally opened by @rudolph9 in cuelang/cue#253

Background

JSON has no concepts of float or int only number. The current behavior of cuelang has float and int as completely disjoint branches on the value lattice. Further, any concrete number with a dot . implicitly is a float (e.g. 0.0) and any number without a dot implicitly is an int (e.g. 0).

This causes an error in the following example:

foo: 0
foo: float

A couple tickets related to this behavior:
cuelang/cue#252
cuelang/cue#233

Objective

Unify float and int as simply number which would make for example {foo: 0.0} & {foo: 0} valid cuelang.

Transition

Phase 1:

  • Change the behavior of float to be synonymous with number.
  • Change the behavior of int to declare a number with a constraint that does not allow decimal values.
  • Make any concrete decoration of a number (e.g. 0, 0.0, 1.2, 5`, etc.) implicitly declare a number.

Phase 2:

  • declare float deprecated
  • Configure cue fmt to change all usages of float to number

Phase 3:

  • remove builtin support for float

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions