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

Possibility for call-by reference #214

Open
sebffischer opened this issue Oct 24, 2024 · 0 comments
Open

Possibility for call-by reference #214

sebffischer opened this issue Oct 24, 2024 · 0 comments
Labels
meta-discussion Discussions and resources theme-internals Relates to internal operations of the language type-design Discussion regarding design of enhancements or project at large

Comments

@sebffischer
Copy link
Collaborator

sebffischer commented Oct 24, 2024

I am not sure whether this is desirable but I think it might be worth to consider the possibility for allowing call-by-reference semantics. In C++, e.g., the & in the function signature void mutate(double& x); causes the x to be passed by-reference and is therefore mutable from within the function.

I think there are some arguments in favor of allowing for a standardized interface for reference semantics:

  1. In R, data.table is a very widely used library and uses references semantics for performance. So there is demand for such a mechanism. Another prominent example is R6, which definitely also has it's use-cases, e.g. for logging via the lgr package.
  2. If one does not provide a proper mechanism for reference semantics, people will still be able to achieve this in a probably more hacky way.
  3. If one provides an Environment structure, the language already has references semantics so extending this to other data types does not seem to big of a stretch.

The argument against references semantics I think is that it introduces a lot of complexity, consider e.g. the whole shared vs exclusive reference mechanism in rust.

@sebffischer sebffischer added theme-internals Relates to internal operations of the language type-design Discussion regarding design of enhancements or project at large meta-discussion Discussions and resources labels Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-discussion Discussions and resources theme-internals Relates to internal operations of the language type-design Discussion regarding design of enhancements or project at large
Projects
None yet
Development

No branches or pull requests

1 participant