Re: What is the "right" way to create a generic type getter (and setter) ?

2018-03-15 Thread Cym13 via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:48:52 UTC, James Blachly wrote: On Wednesday, 14 March 2018 at 22:58:25 UTC, ag0aep6g wrote: You can probably get around the (manually maintained?) `FIELDS` array with `.tupleof` or something similar: static foreach (i, f; S.tupleof) { case

Re: What is the "right" way to create a generic type getter (and setter) ?

2018-03-15 Thread James Blachly via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 22:58:25 UTC, ag0aep6g wrote: You can probably get around the (manually maintained?) `FIELDS` array with `.tupleof` or something similar: static foreach (i, f; S.tupleof) { case __traits(identifier, f): } Any pointers / design patterns on this

Re: What is the "right" way to create a generic type getter (and setter) ?

2018-03-14 Thread ag0aep6g via Digitalmars-d-learn
On 03/14/2018 11:13 PM, James Blachly wrote: Suppose I have a struct (which is really a memory map of a data file I am reading in) with too many data members to reasonably code getters/setters for by hand.  I wish to either retrieve individual values or set individual values, which could be

What is the "right" way to create a generic type getter (and setter) ?

2018-03-14 Thread James Blachly via Digitalmars-d-learn
For context, please keep in mind I am coming from a python background, but am very much enjoying strong typing, although it is taking some significant adjustment. Suppose I have a struct (which is really a memory map of a data file I am reading in) with too many data members to reasonably