This applies both to the rule name and to the terminology used for that, namely
for a non-empty sequence of decimal digits.
While 'natural' was meant to describe a natural number (i.e. a non-negative
integer: 0, 1, 2, ...), it is perhaps not a familiar term to many users.
On the other hand, 'integer', while often used in programming languages for this
kind of thing, is not ideal as integers may be negative.
Also, assuming type inference, a lone numeral like `17` may actually not denote
an integer number at all, because it may actually denote a group element if type
inference turns it into `17group`, and group elements are not integers.
All in all, 'numeral' seems like a good term, also according to its dictionary
definition. It is used in the Java grammar to denote this kind of thing, for
instance.
If, in the future, we want to allow hexadecimal, octal, or binary notation, we
could rename this to `decimal-numeral`, introduce `hexadecimal-numeral`,
`octal-numeral`, and `binary-numeral`, and `numeral` as the union of these.
This does not change the grammar. It merely updates some text in the comments,
which shows a rule that was changed at some point but its copy in the comments
was not properly updated.
Thanks to @bendyarm for noticing this.
This removes the rule for `integer` and uses `natural` for all numeric literals.
Otherwise, lexing would be context-dependent for no good reason.
This is consistent with the lexer and parser of the Leo compiler.
Note that, for instance, `-1field` is not a literal, but rather a unary
expression where `-` is applied to the literal `1field`. This is consistent with
other languages too.
Types are now required in variable and constant declarations (including for loop
variables), and for literals (i.e. there are no longer untyped literals).
This "merges" the two previous slightly different notions of array type
dimensions and array expression dimension(s) into one notion of array
dimensions, in which the dimensions have to be natural numbers. (Previously,
array type dimensions were allowed to be unspecified (via underscores), while
array expression dimensions had to be specified.)
The purpose of this RFC is to:
- Provide user documentation for this feature in a more accessible way than
in the text for https://github.com/AleoHQ/leo/pull/1410, particularly after
that PR is closed.
- Record the discussion in a recent meeting about broadening the notion of const
function to map const arguments to const results rather than requiring const
arguments, as a possible future extension.