digitalmars.D.learn - Duplicate class/interface/struct completely
- Michelle Long (13/13) Mar 25 2019 Given a class/interface/struct, I'd like to duplicate it's design
- Bastiaan Veelo (6/9) Mar 26 2019 This sounds like mocking, this answer might be of help:
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.
Mar 25 2019
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.
Mar 26 2019