Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Document Variable References Better #6

Open
WalkerCodeRanger opened this issue Mar 1, 2018 · 0 comments
Open

Document Variable References Better #6

WalkerCodeRanger opened this issue Mar 1, 2018 · 0 comments

Comments

@WalkerCodeRanger
Copy link
Member

Can you have a variable of type ref ref T or does that always collapse to ref T? What about ref var ref var T?

It seems like ref ref T should collapse/convert to ref T. But the same logic doesn't seem to hold for ref var ref var T.

var x = 5; // x: int
var y = ref var x; // y: ref var int (note ref x would yield the type ref int)
var z = ref var y; // z: ref var ref var int
var zz = ref var z; // zz: ref var ref var ref var int

If ref ref T converts to ref T then ref ref var T should be ref var T. Maybe you simply aren't allowed to take a reference to a variable of type ref (var) T. However, how would that play with generics where you are unsure if the type is a reference or not?

Types like ref var ref T also need to be considered.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant