dotnet / dotnet/csharpstandard

Variables and Variable References

Open
#324 17 comments 0 reactions 0 assignees View on GitHub
type: clarity
Dominant language
C#
Stars
815
Forks
99
Avg merge
1d 14h
Merged PRs (30d)
16

Description

This Issue *replaces* Issue #270, ‘Revising the Definition of “Variable Reference”.’

I’ve put each proposal in a separate Comment, so you can record a thumb-up/down for each.

## Defining two kinds of variable references

The key to my proposals below is to have two flavors of variable reference: modifiable and non-modifiable, so we can adequately spec the following V7 features:

- Input parameters
- Methods/delegates with ref returns
- local ref variables
- Conditional expressions having a ref result
- ref assignment

## Variable reference

10.5 Variable references says

> A *variable_reference* is an *expression* that is classified as a variable. A *variable_reference* denotes a storage location that can be accessed both to fetch the current value and to store a new value.
> ```ANTLR
> variable_reference
> : expression
> ;
> ```
> > *Note*: In C and C++, a *variable_reference* is known as an *lvalue*. *end note*

**Proposal 1**: We should use the term “variable reference” (rather than “variable”) in all contexts involving an expression that denotes a variable.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.