Re: pragma msg field name?

2023-06-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/27/23 6:34 PM, Adam D Ruppe wrote: On Tuesday, 27 June 2023 at 22:20:22 UTC, Chris Katko wrote:     pragma(msg, t.stringof); // does not see any new fields! D's declarations are all order-independent, in theory those foreaches are done simultaneously, so it is kinda a race

Re: pragma msg field name?

2023-06-27 Thread Chris Katko via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 22:34:17 UTC, Adam D Ruppe wrote: On Tuesday, 27 June 2023 at 22:20:22 UTC, Chris Katko wrote: pragma(msg, t.stringof); // does not see any new fields! D's declarations are all order-independent, in theory those foreaches are done simultaneously,

Re: pragma msg field name?

2023-06-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 22:20:22 UTC, Chris Katko wrote: pragma(msg, t.stringof); // does not see any new fields! D's declarations are all order-independent, in theory those foreaches are done simultaneously, so it is kinda a race condition. In practice, the compiler

Re: pragma msg field name?

2023-06-27 Thread Chris Katko via Digitalmars-d-learn
Does anyone know why the new variables don't show up after the static foreach? I have a struct, it has some marked fields. I want to note those fields at compile time and make some similarly named fields like myField becomes myField__replicated. The code doesn't _have_ to be inside the

Re: pragma msg field name?

2023-06-27 Thread Dennis via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 05:03:01 UTC, Jonathan M Davis wrote: However, I would point out that getSymbolsByUDA gives you symbols, not strings, whereas pragma(msg, ...) wants a string. For some time now, it accepts any number of objects, which will all be converted to strings and

Re: pragma msg field name?

2023-06-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 04:25:13 UTC, Chris Katko wrote: How do I get just the field name? __traits(identifier, field) And why does it think this is a run-time value? It is the same as if you wrote `Class.field`

Re: pragma msg field name?

2023-06-26 Thread Chris Katko via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 04:56:19 UTC, Ali Çehreli wrote: On 6/26/23 21:25, Chris Katko wrote: > How do I get just the field name? I know .tupleof, which you can typeof() as well: class myObject{ int field1, field2, field3; static foreach(field; typeof(this).tupleof) {

Re: pragma msg field name?

2023-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 26, 2023 10:25:13 PM MDT Chris Katko via Digitalmars-d-learn wrote: > inside a static foreach I can do > > ``` > enum rep; > > class myObject{ > int field1, field2, field3; > > static foreach(field; getSymbolsByUDA!(typeof(this), rep)) > { > pragma(msg, field); // fails >

Re: pragma msg field name?

2023-06-26 Thread Ali Çehreli via Digitalmars-d-learn
On 6/26/23 21:25, Chris Katko wrote: > How do I get just the field name? I know .tupleof, which you can typeof() as well: class myObject{ int field1, field2, field3; static foreach(field; typeof(this).tupleof) { pragma(msg, field.stringof); } static

pragma msg field name?

2023-06-26 Thread Chris Katko via Digitalmars-d-learn
inside a static foreach I can do ``` enum rep; class myObject{ int field1, field2, field3; static foreach(field; getSymbolsByUDA!(typeof(this), rep)) { pragma(msg, field); // fails pragma(msg, fullyQualifiedName!field); // works } } ``` error for pragma(msg, field) ```