Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Add initial RFC for type casts. #1056

Merged
merged 2 commits into from
Jul 1, 2021
Merged

[RFC] Add initial RFC for type casts. #1056

merged 2 commits into from
Jul 1, 2021

Conversation

acoglio
Copy link
Collaborator

@acoglio acoglio commented Jun 22, 2021

Closes #1057.

@acoglio acoglio added the RFC label Jun 22, 2021
@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #1056 (3413f60) into master (ba0c931) will increase coverage by 0.17%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1056      +/-   ##
==========================================
+ Coverage   75.66%   75.84%   +0.17%     
==========================================
  Files         439      438       -1     
  Lines       17771    17805      +34     
==========================================
+ Hits        13447    13504      +57     
+ Misses       4324     4301      -23     
Impacted Files Coverage Δ
ast/src/input/input_value.rs 79.27% <0.00%> (-2.41%) ⬇️
input/src/errors/parser.rs 25.49% <0.00%> (-1.05%) ⬇️
compiler/src/value/integer/integer.rs 81.64% <0.00%> (-0.18%) ⬇️
asg/src/error/mod.rs 54.19% <0.00%> (ø)
asg/src/expression/tuple_init.rs 75.00% <0.00%> (ø)
compiler/src/value/integer/macros.rs 42.30% <0.00%> (ø)
grammar/src/main.rs
asg/src/expression/mod.rs 79.54% <0.00%> (+0.45%) ⬆️
compiler/src/phases/reducing_director.rs 48.09% <0.00%> (+0.54%) ⬆️
imports/src/parser/parse_package.rs 57.69% <0.00%> (+0.82%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ba0c931...3413f60. Read the comment docs.

(at least, not for production code).
Presumably, the behavior of type casts in those programming languages
is motivated by efficiency of execution, at least in part.
Since in Leo the input data is avaialable at compile time,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo -> "available". Also, do we want to distinguish between compile-to-IR-or-R1CS time and proof generation time in this discussion, or is that too tangential?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it may be too tangential too at this level. (If you agree, you or I can click the 'Resolve conversation' button here.)

let r_low16: u32 = r & 0xFFFF; // assuming we have bitwise ops and hex literals
let s: u16 = r_low16 as u16; // no value change here
```

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value-preserving casts alternative does not prevent the later addition of other operators that change the value and type, such as the re-interpretation between signed and unsigned. It might improve clarity of code to have a syntactic difference between value-preserving and value-changing casts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree.

Copy link
Collaborator

@bendyarm bendyarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. How are we going to decide between the alternatives?

@acoglio
Copy link
Collaborator Author

acoglio commented Jun 29, 2021

Looks good. How are we going to decide between the alternatives?

Maybe we can start a discussion at this Wednesday's sync.

Copy link
Contributor

@gluax gluax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acoglio acoglio merged commit 322518c into master Jul 1, 2021
@acoglio acoglio deleted the rfc-type-casts branch July 1, 2021 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Write RFC for type casts.
4 participants