mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-13 08:47:17 +03:00
[RFC] Minor edits to the text.
This commit is contained in:
parent
aa29ce30d4
commit
f3a1352ec2
@ -72,9 +72,7 @@ exponential-expression = cast-expression
|
|||||||
```
|
```
|
||||||
There is no need to modify the `keyword` rule
|
There is no need to modify the `keyword` rule
|
||||||
because it already includes `as` as one of the keywords.
|
because it already includes `as` as one of the keywords.
|
||||||
Note the use of `integer-type` in the `cast-expression` rule;
|
Note the use of `integer-type` in the `cast-expression` rule.
|
||||||
an alternative is to use `type` there
|
|
||||||
and check post-parsing that the type is in fact an integer one.
|
|
||||||
|
|
||||||
The above grammar rules imply that casts bind
|
The above grammar rules imply that casts bind
|
||||||
tighter than binary operators and looser than unary operators.
|
tighter than binary operators and looser than unary operators.
|
||||||
@ -111,8 +109,7 @@ but cause errors when values are not representable in the new types;
|
|||||||
and _values-changing casts_,
|
and _values-changing casts_,
|
||||||
which never cause errors but may change the mathematical values.
|
which never cause errors but may change the mathematical values.
|
||||||
|
|
||||||
Based on discussion and consensus within the Leo team,
|
This RFC proposes value-preserving casts;
|
||||||
this RFC proposes value-preserving casts;
|
|
||||||
value-changing casts are discussed in the 'Alternatives' section,
|
value-changing casts are discussed in the 'Alternatives' section,
|
||||||
for completeness.
|
for completeness.
|
||||||
|
|
||||||
@ -129,7 +126,7 @@ When values are to be changed, separate (built-in) functions can be used,
|
|||||||
e.g. to mask bits and achieve the same effect as
|
e.g. to mask bits and achieve the same effect as
|
||||||
the value-changing casts discussed below.
|
the value-changing casts discussed below.
|
||||||
|
|
||||||
This approach Leo's treatment of potentially erroneous situations like integer overflows.
|
This approach is consistent with Leo's treatment of potentially erroneous situations like integer overflows.
|
||||||
The principle is that developers should explicitly use
|
The principle is that developers should explicitly use
|
||||||
operations that may overflow if that is their intention,
|
operations that may overflow if that is their intention,
|
||||||
rather than having those situation possibly occur unexpectedly.
|
rather than having those situation possibly occur unexpectedly.
|
||||||
@ -201,7 +198,7 @@ As mentioned above, an alternative semantics for casts is value-changing:
|
|||||||
10. `iN` to `uN`: re-interpret as unsigned
|
10. `iN` to `uN`: re-interpret as unsigned
|
||||||
Except for the 1st and 3rd cases, the value may change.
|
Except for the 1st and 3rd cases, the value may change.
|
||||||
|
|
||||||
This approach is common in other programming languages.
|
This value-changing approach is common in other programming languages.
|
||||||
However, it should be noted that other programming languages
|
However, it should be noted that other programming languages
|
||||||
typically do not check for overflow in integer operations either
|
typically do not check for overflow in integer operations either
|
||||||
(at least, not for production code).
|
(at least, not for production code).
|
||||||
|
Loading…
Reference in New Issue
Block a user