Replies: 11 comments
-
Doesn't this defeat the purpose of |
Beta Was this translation helpful? Give feedback.
-
@YotaXP Expanding on what I wrote, you could do the following:
|
Beta Was this translation helpful? Give feedback.
-
@YotaXP ref-like types are to be subject to basically the same restrictions that a current
|
Beta Was this translation helpful? Give feedback.
-
Tagging @VSadov |
Beta Was this translation helpful? Give feedback.
-
I'd like to be able to do this: ref struct HigherLevelMessage
{
ref LowerLevelMessage message;
public ctor(ref LowerLevelMessage message)
{
this.message = ref message;
}
} Will it be possible? |
Beta Was this translation helpful? Give feedback.
-
Will the |
Beta Was this translation helpful? Give feedback.
-
We discussed some support for wrapping single variable into a span. The issue gets pretty complex when you need to ensure life times. It seems simple - if you wrap a local, then the resulting span value cannot leave the local's scope, if you wrap a heap location, then it can escape anywhere. Where it becomes a problem is when ref parameters/returns/local are involved.
We may need a special language feature that specificaly "takes a ref and wraps it in a span", and we will track result as not escapable, unless we are sure the input ref was a heap ref. Basically - this functionality may be introduced, but that would not be via a call to an ordinary method/constructor. |
Beta Was this translation helpful? Give feedback.
-
@sharwell - This is of interest to me too. It would be helpful to support struct conversions that allow converting to or from a We can already convert On a similar note we also can't have a property that both returns and accepts a |
Beta Was this translation helpful? Give feedback.
-
@Korporal
These methods are very specifically marked unsafe. There may well not be appetite to make them seem like innocuous conversions. I think the Unsafe class ought to make you feel a little bit naughty every time you use it. |
Beta Was this translation helpful? Give feedback.
-
I'm more or less asking for what the OP asks for here, what one does inside such operators is immaterial surely. This could also be solved more easily by supporting |
Beta Was this translation helpful? Give feedback.
-
See also this issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently the following is not allowed:
It would be helpful if limitation was removed, opening the door for the following declaration:
This change would improve the ability to create data processing APIs that perform well for zero-, single-, and multi-element collections. See dotnet/roslyn#22580.
Beta Was this translation helpful? Give feedback.
All reactions