Hacker News new | ask | show | jobs
by pjmlp 1731 days ago
Kind of, if it is a struct with destructors you need to ensure a region exists.

So either do something like

    using MyStructType something = new MyStructType ()
Or a more FP like stuff with

    myVar.WithXYZResource(res => { /* .... */ })
And then consider if it should be a ref struct, so that is only stack allocated.

This from C# point of view, in something like D, there would be another set of considerations.

Still much easier than "in your face ownership management" though, yes.

1 comments

Well, destructors come up if you have non-memory resources to manage, and there you do go back to ownership and deterministic destruction issues.