Can we just have struct inheritence already?
Exil
Exil at gmall.com
Mon Jun 10 00:29:08 UTC 2019
On Sunday, 9 June 2019 at 21:13:50 UTC, Manu wrote:
>
> Classic response.
>
> Because:
> 1, that sucks!
> 2, DRY; some structs have common elements. (how can anyone find
> that
> surprising?) I don't want to repeat them all over the place!
Wouldn't this be the same as having a struct of those elements,
and having the struct as a variable of those structs? Alias this
just takes that one step further and you don't even have to
reference the struct that defines those elements.
> 3, syntax highlighting breaks from that point down !!!
> 4, debuginfo breaks from that point down !!!
> 5, debugging experience is embarrassing !!!
This is a larger problem with D. It is a complicated language
like C++ but it has a very small community in comparison. Not
sure about syntax highlighting, do you mean auto complete?
Otherwise that'd be new. Haven't had debugging break from this
style of mixin, though there is plenty wrong with D's debugging.
A lot of these issues also apply to templates, though I wouldn't
want that feature removed...
> 6, it depends on naming conventions (of the base
> object/function),
> which are brittle
Maybe explain this a bit more, so you'd want "override" to work
with structs then? But you don't want the functions to be
"virtual"?
> 7, meta to determine the base type is problematic and very
> complex if
> it wants to be accurate
With the mixin you could add an alias. It'd only work with
structs that make use of the mixin, but I imagine you'd only want
to to work with them anyways. At least I don't know any other
library that uses this pattern, and I only need it for a few
things in my codebase.
More information about the Digitalmars-d
mailing list