Skip to content

Possibility for call-by reference #214

@sebffischer

Description

@sebffischer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    meta-discussionDiscussions and resourcestheme-internalsRelates to internal operations of the languagetype-designDiscussion regarding design of enhancements or project at large

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions