Skip to content

I'm confused about the name of the 'ref struct' #97961

Answered by En3Tho
paxhujing asked this question in Q&A
Discussion options

You must be logged in to vote

looks like it's telling you that the struct is a reference-like type

Correct would be "by-reference-like type". It means that compiler should enforce the same rules for such a struct as for example ref int.
Living on the stack is an implementation detail/constraint. It could be theoretically possible for a class to have ref field for example. The problems are:

  1. making sure that ref field on heap types are only heap referencing or object should be considered dead when functions exits (lifetime issue basically)
  2. making sure GC can support arbitrary heap-to-heap refs without a huge perf hit because that ref can point to basically arbitrary field of the object.

So I wouldn't really tie nami…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by paxhujing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants