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 cond

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 simultane

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 com

Re: pragma msg field name?

2023-06-27 Thread Chris Katko via Digitalmars-d-learn
io): ```D import std; struct multiplayerObject2 { ushort type; ushort type2; float x, y; static foreach(t; typeof(this).tupleof) { pragma(msg, t.stringof); mixin("bool " ~ t.stringof ~ "25;"

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
eof) { pragma(msg, field.stringof); } static foreach(MemberType; typeof(typeof(this).tupleof)) { pragma(msg, MemberType); } } The output: field1 field2 field3 int int int I had to consult what I wrote years ago: http://ddili.org/ders/d.en/tuples.html#ix_tuples..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)) > { >

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 fore

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

Re: Can a call to pragma(msg, __FILE__, ...) be mixin templatized?

2020-08-18 Thread Simen Kjærås via Digitalmars-d-learn
import std.conv : to; string result = `pragma(msg, "`~file~`(", `~line.to!string~`, "): "`; static foreach (e; Args) { result ~= `, `~e.stringof; } return result~`);`; } mixin(ctLog!("This ", "is ", "module ", "scope.&qu

Re: Can a call to pragma(msg, __FILE__, ...) be mixin templatized?

2020-08-18 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 18 August 2020 at 08:03:04 UTC, Per Nordlöw wrote: Forgot to mention that I want to support variadic arguments to `ctLog` similar to what is done with And these arguments should be of any template argument kind, not only a compile-time string.

Re: Can a call to pragma(msg, __FILE__, ...) be mixin templatized?

2020-08-18 Thread Per Nordlöw via Digitalmars-d-learn
On Monday, 17 August 2020 at 22:37:12 UTC, Simen Kjærås wrote: mixin template ctLog(string msg, string file = __FILE__, size_t line = __LINE__) { pragma(msg, file, "(", line, "): ", msg); } Thanks. Forgot to mention that I want to support variadic arguments to `ctLog

Re: Can a call to pragma(msg, __FILE__, ...) be mixin templatized?

2020-08-17 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 17 August 2020 at 21:18:41 UTC, Per Nordlöw wrote: I'm using pragma(msg, __FILE__, "(", __LINE__, ",1): Debug: ", "A useful debug message"); to print compile-time information formatted as standard compiler diagnostics. These are picked up

Can a call to pragma(msg, __FILE__, ...) be mixin templatized?

2020-08-17 Thread Per Nordlöw via Digitalmars-d-learn
I'm using pragma(msg, __FILE__, "(", __LINE__, ",1): Debug: ", "A useful debug message"); to print compile-time information formatted as standard compiler diagnostics. These are picked up by Emacs Flycheck and overlayed in the editor and listen in

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread wjoe via Digitalmars-d-learn
On Thursday, 14 May 2020 at 10:58:34 UTC, WebFreak001 wrote: On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an a

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread WebFreak001 via Digitalmars-d-learn
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer. for simple hex/binary/etc printing use import std

Re: Easy way to format int in pragma msg ?

2020-05-14 Thread John Chapman via Digitalmars-d-learn
On Thursday, 14 May 2020 at 09:49:15 UTC, wjoe wrote: Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer. import std.string; pragma(msg, format("%x",

Easy way to format int in pragma msg ?

2020-05-14 Thread wjoe via Digitalmars-d-learn
Is there an easy way to print an int in hexadecimal, octal or binary representation ? The documentation on pragma(msg, ...) and a quick web search didn't provide an answer.

Improper display of Cyrillic in `pragma (msg, ...)` on Windows

2016-08-05 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, To view Cyrillic CMD on Windows can be used `std.process.executeShell("chcp 65001 ");` and it works. What should I use to change the encoding to UTF-8 to the compiler messages in `pragma(msg, ...)` on Visual D? // import std.stdio, std.proc

Re: pragma(msg,

2011-01-30 Thread Ellery Newcomer
ing for an enum string, er, 'propagates' the compile-time-ness to tct!(int,int). Everything is calculated at CT, because it's doable. But when you used pragma(msg, someString), the compiler doesn't know someString can be entirely known at CT. actually, it didn't calculate

Re: pragma(msg,

2011-01-30 Thread Philippe Sigaud
enum string, er, 'propagates' the compile-time-ness to tct!(int,int). Everything is calculated at CT, because it's doable. But when you used pragma(msg, someString), the compiler doesn't know someString can be entirely known at CT. So, there is a difference between pragma(msg, tct!(

Re: pragma(msg,

2011-01-30 Thread Ellery Newcomer
On 01/30/2011 07:40 AM, Philippe Sigaud wrote: On Sun, Jan 30, 2011 at 00:26, Ellery Newcomer wrote: code: template tct(T1,T2){ string tct = T1.stringof ~ " " ~ T2.stringof ~ typeof(true?T1.init:T2.init).stringof; } pragma(msg, tct!(shared(const(int))*, const(int*))

Re: pragma(msg,

2011-01-30 Thread Philippe Sigaud
On Sun, Jan 30, 2011 at 00:26, Ellery Newcomer wrote: > code: > > template tct(T1,T2){ >    string tct = T1.stringof ~ " " ~ T2.stringof ~ >        typeof(true?T1.init:T2.init).stringof; > } > pragma(msg, tct!(shared(const(int))*, const(int*))); > > result:

pragma(msg,

2011-01-29 Thread Ellery Newcomer
code: template tct(T1,T2){ string tct = T1.stringof ~ " " ~ T2.stringof ~ typeof(true?T1.init:T2.init).stringof; } pragma(msg, tct!(shared(const(int))*, const(int*))); result: tct why?