digitalmars.D.learn - Parsing a string to instantiate classes at runtime
- Marduk (12/12) Nov 27 2016 Dear all,
- ag0aep6g (3/6) Nov 27 2016 Can you link that post, please? I can't imagine what "dynamic mixin"
- Marduk (6/8) Nov 27 2016 Sure, it's here:
- ag0aep6g (4/9) Nov 27 2016 Ok, that's a hypothetical. It's "if D had a 'dynamic mixin', then we
- Marduk (2/6) Nov 28 2016 You are right. I misread.
- Jacob Carlborg (6/11) Nov 28 2016 It's possible to bypass the constructors [1].
- Marduk (2/5) Nov 28 2016 Aha! Interesting. Thanks.
- Jacob Carlborg (5/6) Nov 28 2016 Then you can call a custom method that acts as a constructor when the
Dear all, I would like to write a program that: 1. Receives a string from the UI 2. Parses the string 3. Instantiates classes, whose names are contained in the string, passing parts of the string as constructor arguments. From my experience with other programming languages, I suppose I need to define an eval function. I read in an old post in these forums that with a dynamic mixin it is possible to add structures and classes at runtime. I searched "dynamic mixin" but I did not find more information. Any help will be greatly appreciated.
Nov 27 2016
On 11/27/2016 10:02 PM, Marduk wrote:I read in an old post in these forums that with a dynamic mixin it is possible to add structures and classes at runtime. I searched "dynamic mixin" but I did not find more information.Can you link that post, please? I can't imagine what "dynamic mixin" could refer to.
Nov 27 2016
On Sunday, 27 November 2016 at 21:10:30 UTC, ag0aep6g wrote:Can you link that post, please? I can't imagine what "dynamic mixin" could refer to.Sure, it's here: http://forum.dlang.org/post/xmnnsdiuwyjrhkasyuyg forum.dlang.org In that thread they also mention Object.factory, but the documentation says that the class must have either no constructor or the default constructor, which is not my case.
Nov 27 2016
On 11/27/2016 10:19 PM, Marduk wrote:On Sunday, 27 November 2016 at 21:10:30 UTC, ag0aep6g wrote:Ok, that's a hypothetical. It's "if D had a 'dynamic mixin', then we could do fancy things with it." D doesn't have a 'dynamic mixin', so you can't do those fancy things, at least not in the envisioned way.Can you link that post, please? I can't imagine what "dynamic mixin" could refer to.Sure, it's here: http://forum.dlang.org/post/xmnnsdiuwyjrhkasyuyg forum.dlang.org
Nov 27 2016
On Sunday, 27 November 2016 at 21:28:52 UTC, ag0aep6g wrote:Ok, that's a hypothetical. It's "if D had a 'dynamic mixin', then we could do fancy things with it." D doesn't have a 'dynamic mixin', so you can't do those fancy things, at least not in the envisioned way.You are right. I misread.
Nov 28 2016
On 2016-11-27 22:19, Marduk wrote:Sure, it's here: http://forum.dlang.org/post/xmnnsdiuwyjrhkasyuyg forum.dlang.org In that thread they also mention Object.factory, but the documentation says that the class must have either no constructor or the default constructor, which is not my case.It's possible to bypass the constructors [1]. [1] https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L166 -- /Jacob Carlborg
Nov 28 2016
On Monday, 28 November 2016 at 09:33:08 UTC, Jacob Carlborg wrote:It's possible to bypass the constructors [1]. [1] https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L166Aha! Interesting. Thanks.
Nov 28 2016
On 2016-11-29 07:46, Marduk wrote:Aha! Interesting. Thanks.Then you can call a custom method that acts as a constructor when the instance is created this way, if there's a need for it. -- /Jacob Carlborg
Nov 28 2016