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) ```

Re: Scope guards

2023-06-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/26/23 2:42 PM, Cecil Ward wrote: == { size_t p = offset; ++p; scope(exit) { writeOutput( 0, p ); ++p … ++p; return; } == The correctness of its behaviour depends on what the value of p is when it calls writeOutput(), and the value of p is being changed. To be correct, the final value

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 22:19:25 UTC, Jonathan M Davis wrote: On Monday, June 26, 2023 1:09:24 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] [...] I completely agree with everything you said. I merely used aliases to give me the freedom to switch between having text in either

Re: Counting an initialised array, and segments

2023-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 26, 2023 1:09:24 PM MDT Cecil Ward via Digitalmars-d-learn wrote: > No, point taken, a sloppy example. I don’t in fact do that in the > real code. I use dchar everywhere appropriate instead of uint. In > fact I have aliases for dstring and dchar and successfully did an >

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 12:28:15 UTC, Jonathan M Davis wrote: On Monday, June 26, 2023 5:08:06 AM MDT Cecil Ward via Digitalmars-d-learn wrote: On Monday, 26 June 2023 at 08:26:31 UTC, Jonathan M Davis wrote: > On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via > > Digitalmars-d-learn

Re: Scope guards

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 17:41:16 UTC, Paul Backus wrote: On Saturday, 24 June 2023 at 17:00:36 UTC, Cecil Ward wrote: I would like to use scope guards but in the guard I need to get access to some local variables at the end of the routine. This doesn’t really seem to make sense as to how it

Re: Scope guards

2023-06-26 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 24 June 2023 at 17:00:36 UTC, Cecil Ward wrote: I would like to use scope guards but in the guard I need to get access to some local variables at the end of the routine. This doesn’t really seem to make sense as to how it would work, because their values depend on the exact point

Re: Counting an initialised array, and segments

2023-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 26, 2023 5:08:06 AM MDT Cecil Ward via Digitalmars-d-learn wrote: > On Monday, 26 June 2023 at 08:26:31 UTC, Jonathan M Davis wrote: > > On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via > > > > Digitalmars-d-learn wrote: > >> I recently had some problems > >> > >> dchar[]

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 08:26:31 UTC, Jonathan M Davis wrote: On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via Digitalmars-d-learn wrote: I recently had some problems dchar[] arr = [ ‘ ‘, TAB, CR, LF … ]; and I got errors from the compiler which led to me having to count the elements

Re: Counting an initialised array, and segments

2023-06-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via Digitalmars-d-learn wrote: > I recently had some problems > > dchar[] arr = [ ‘ ‘, TAB, CR, LF … ]; > > and I got errors from the compiler which led to me having to > count the elements in the initialiser and declare the array with > an