Re: DMD 2.092 and DIP 25

2020-05-30 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 May 2020 at 07:30:17 UTC, Max Samukha wrote: On Saturday, 30 May 2020 at 07:00:07 UTC, Mike Parker wrote: https://run.dlang.io/is/aOZqww Since 2.067.1: Success and no output Thanks! I forgot that run.dlang.io supports all those old compilers.

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Seb via Digitalmars-d-learn
On Saturday, 30 May 2020 at 07:00:07 UTC, Mike Parker wrote: The following declarations now give a deprecation warning: ```d struct ErrorInfo { private: char[32] _error; char[96] _message; public @nogc nothrow @property: /** Returns the string "Missing Symbol" to indicate a

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Max Samukha via Digitalmars-d-learn
On Saturday, 30 May 2020 at 07:00:07 UTC, Mike Parker wrote: I find it rather annoying, as I'm returning `const(char)*` and not `char*`, but it is what it is. My question is, if I add `return` to the function declarations, will this compile all the way back to DMD 2.067 *without*

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 May 2020 at 07:30:17 UTC, Max Samukha wrote: On Saturday, 30 May 2020 at 07:00:07 UTC, Mike Parker wrote: https://run.dlang.io/is/aOZqww Since 2.067.1: Success and no output Thanks, Max (and you, too, Seb). I had forgotten that run.dlang.io supports compilers going so

Re: How to pre build vibe-d dub package

2020-05-30 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 30 May 2020 at 00:12:20 UTC, kookman wrote: On Friday, 29 May 2020 at 11:45:24 UTC, Andre Pany wrote: André I do it by defining a configuration “build-deps” in my dub.sdl with target type “none” and then doing the build as two steps in the dockerfile: ``` dockerfile ...

DMD 2.092 and DIP 25

2020-05-30 Thread Mike Parker via Digitalmars-d-learn
The following declarations now give a deprecation warning: ```d struct ErrorInfo { private: char[32] _error; char[96] _message; public @nogc nothrow @property: /** Returns the string "Missing Symbol" to indicate a symbol load failure, and the name of a library to

Re: Logging best practices

2020-05-30 Thread mw via Digitalmars-d-learn
On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm wrote: Hello. Is there a current "Best Practices" for logging in D? For the actual logging, I know of `std.experimental.logger`. However, the `experimental` has kept me away from it. Is it good, or are there any better

Re: Logging best practices

2020-05-30 Thread mw via Digitalmars-d-learn
On Monday, 29 April 2019 at 16:02:25 UTC, Arun Chandrasekaran wrote: std.experimental.logger is perfectly thread safe. However printing the logging thread ID is still pending with this PR https://github.com/dlang/phobos/pull/6978 Also is any file logger thread safe?

Re: Logging best practices

2020-05-30 Thread Andre Pany via Digitalmars-d-learn
On Saturday, 30 May 2020 at 18:17:21 UTC, mw wrote: On Thursday, 25 April 2019 at 10:33:00 UTC, Vladimirs Nordholm wrote: Hello. Is there a current "Best Practices" for logging in D? For the actual logging, I know of `std.experimental.logger`. However, the `experimental` has kept me away

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/30/20 3:00 AM, Mike Parker wrote: The following declarations now give a deprecation warning: ```d struct ErrorInfo { private:     char[32] _error;     char[96] _message; public @nogc nothrow @property:     /**     Returns the string "Missing Symbol" to indicate a symbol load

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread mw via Digitalmars-d-learn
On Saturday, 30 May 2020 at 22:21:14 UTC, Paul Backus wrote: enum f(string x) = "_" ~ x; int main() { mixin("int ", f!"x", " = 3;"); return _x; } This uses a templated [1] manifest constant [2] to generate the variable name at compile time, and a mixin statement [3] to insert the

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 30 May 2020 at 23:39:31 UTC, mw wrote: Thank you all for the reply. I hate to write boilerplate code: class Point { private int _x; publicint x() {return _x;} public Point x(int v) {_x=v; return this;} ... // ... y, z } this is what I've got: $ cat b.d

Re: DMD 2.092 and DIP 25

2020-05-30 Thread Mike Parker via Digitalmars-d-learn
On Saturday, 30 May 2020 at 16:14:34 UTC, Steven Schveighoffer wrote: This is not about const or not, it's about lifetime management. For example, this would return a pointer to a stack frame that is about to go away: const(char)* foo() { ErrorInfo info; return info.message; } I

how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread mw via Digitalmars-d-learn
I want to generate a new symbol (new variable name) from existing one: e.g. in C: $ cat t.c #define f(x) _##x int main() { int f(x) = 3; return _x; } $ make t cc t.c -o t $ ./t $ echo $? 3 I

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread Johannes Loher via Digitalmars-d-learn
On Saturday, 30 May 2020 at 23:39:31 UTC, mw wrote: On Saturday, 30 May 2020 at 22:21:14 UTC, Paul Backus wrote: [...] Thank you all for the reply. I hate to write boilerplate code: [...] import std.stdio : writeln; mixin template f(T, string name, T value = T.init) { mixin("T _" ~

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 30 May 2020 at 22:06:30 UTC, mw wrote: I want to generate a new symbol (new variable name) from existing one: e.g. in C: $ cat t.c #define f(x) _##x int main() { int f(x) = 3; return _x; } $ make t cc t.c -o t $ ./t $ echo

Re: how to achieve C's Token Pasting (##) Operator to generate variable name in D?

2020-05-30 Thread kinke via Digitalmars-d-learn
Using a mixin: string f(string x) { return "_" ~ x; } int main() { mixin("int "~f("x")~" = 3;"); return _x; }

Garbage Collection Issue

2020-05-30 Thread Marius Cristian Baciu via Digitalmars-d-learn
I am encountering a strange problem with the GC on a specific platform: at the first attempt to clear the current memory pool to make room for a new allocation, the GC considers that the page in which the main thread resides (the one created in the init function of the GC) can be freed..