March 26, 2019 Duplicate class/interface/struct completely | ||||
---|---|---|---|---|
| ||||
Given a class/interface/struct, I'd like to duplicate it's design exactly, as if I copied and pasted directly from the source and just changed the name. I need to inspect the contents too. Is this possible with D? Main things I'm thinking will fail are (multiple) alias this unless there is a way to get which variables are aliased to this. The idea is to be able to make sure one can modify a class and drop it in for the original and it work in all cases. With alias this, it can fail unless we can alias it too. struct X { int y; alias this y; } struct XX { mixin DupStruct!X; } If DupStruct cannot handle the alias this then XX can fail to mimic X completely. |
March 26, 2019 Re: Duplicate class/interface/struct completely | ||||
---|---|---|---|---|
| ||||
Posted in reply to Michelle Long | On Tuesday, 26 March 2019 at 05:29:08 UTC, Michelle Long wrote: > The idea is to be able to make sure one can modify a class and drop it in for the original and it work in all cases. With alias this, it can fail unless we can alias it too. This sounds like mocking, this answer might be of help: https://forum.dlang.org/post/gdfvbrknbnbfunycbvwd@forum.dlang.org I don’t know the capabilities of these libraries, but you may want to have a look. Bastiaan. |
Copyright © 1999-2021 by the D Language Foundation