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

Proposal: readonly ref operators #128

Closed
orthoxerox opened this issue Feb 16, 2017 · 1 comment
Closed

Proposal: readonly ref operators #128

orthoxerox opened this issue Feb 16, 2017 · 1 comment

Comments

@orthoxerox
Copy link

Problem

Structs are commonly used in game engines and standalone math libraries to store coordinates, transformation matrices and other similar values. Operators are the most convenient way to expose operations on these structs.

However, operators require that their parameters are passed by value. Copying large structs takes up to 40% of the execution time in microbenchmarks.

Solution

If #38 is implemented, readonly ref operators can be introduced. They are created by marking their parameters with in ref kind.

The following operators should be compiled into a void-returning method with 1 or 2 in parameters and one out parameter (this is faster than returning the result):

  • unary +, -
  • binary +, -, *, /, %, &, |, ^, <<, >>

The following methods should be compiled into a bool-returning method with 1 or 2 in parameters:

  • unary true, false
  • binary ==, !=, >, <, >=, <=

Open questions

Should it be possible to have one in parameter and one RefKind.None parameter for passing smaller value types or reference types?

@orthoxerox
Copy link
Author

Works since 7.2. Kudos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants