| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
July 30 By-ref opaque structs | ||||
|---|---|---|---|---|
| ||||
Opaque structs are typically used as pointers.
However they can be useful for payloads in D with dynamically sized structs.
So let's make this a little easier on ourselves, and make opaque structs always by-ref if it is were otherwise by-value (and then error) and allow them to be the last field of a struct.
This has a nice usage in sumtypes:
As it means we don't have to link against or use random None's all over codebases that are not linking against druntime, but we can still define it in object.d | ||||
September 01 Re: By-ref opaque structs | ||||
|---|---|---|---|---|
| ||||
Paul Backus Posted in reply to Richard (Rikki) Andrew Cattermole | On Thursday, 30 July 2026 at 01:18:26 UTC, Richard (Rikki) Andrew Cattermole wrote: > So let's make this a little easier on ourselves, and make opaque structs always by-ref if it is were otherwise by-value (and then error) and allow them to be the last field of a struct. Why not simply use | |||
September 06 Re: By-ref opaque structs | ||||
|---|---|---|---|---|
| ||||
Ogion Posted in reply to Richard (Rikki) Andrew Cattermole | On Thursday, 30 July 2026 at 01:18:26 UTC, Richard (Rikki) Andrew Cattermole wrote: > This has a nice usage in sumtypes:
As it means we don't have to link against or use random None's all over codebases that are not linking against druntime, but we can still define it in object.d I use
| |||
September 23 Re: By-ref opaque structs | ||||
|---|---|---|---|---|
| ||||
Quirin Schroll Posted in reply to Richard (Rikki) Andrew Cattermole | On Thursday, 30 July 2026 at 01:18:26 UTC, Richard (Rikki) Andrew Cattermole wrote: > Opaque structs are typically used as pointers.
However they can be useful for payloads in D with dynamically sized structs. If anything, we should make the practice of using a 0-size array obsolete and use an attribute or some other indicator for such a dynamically sized payload array. Indexing a 0-size array just looks wrong. Ideally, it would be something like | |||
14 hours ago Re: By-ref opaque structs | ||||
|---|---|---|---|---|
| ||||
Atila Neves Posted in reply to Paul Backus | On Tuesday, 1 September 2026 at 20:30:13 UTC, Paul Backus wrote: > On Thursday, 30 July 2026 at 01:18:26 UTC, Richard (Rikki) Andrew Cattermole wrote: >So let's make this a little easier on ourselves, and make opaque structs always by-ref if it is were otherwise by-value (and then error) and allow them to be the last field of a struct.
Why not simply use This. | |||
Permalink
Reply