Re: How to check that import module will succeed?

2019-07-26 Thread evilrat via Digitalmars-d-learn
On Friday, 26 July 2019 at 14:56:37 UTC, Andrey Zherikov wrote: Even without static if I get the same result: mixin template my_import(alias modName) { mixin("import " ~ modName ~ ";"); } mixin my_import!"mymod"; pragma(msg,fullyQualifiedName!(myfunc)); // Error: undefined identifier

Re: Is betterC affect to compile time?

2019-07-26 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 25 July 2019 at 14:20:03 UTC, Ali Çehreli wrote: On 07/25/2019 05:46 AM, Oleg B wrote: On Thursday, 25 July 2019 at 12:34:15 UTC, rikki cattermole wrote: Those restrictions don't stop at runtime. It's vary sad. What reason for such restrictions? It's fundamental idea or

Re: Is betterC affect to compile time?

2019-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2019 6:13:38 PM MDT Mike Franklin via Digitalmars-d- learn wrote: > On Thursday, 25 July 2019 at 18:37:49 UTC, Jonathan M Davis wrote: > > There's probably at least one bug report on it, but as I > > understand it, it's not a bug in the sense that the > > implementation is

cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } } template f(handlers...) { auto ref f(T)(auto ref T value) { return value.hook!handlers; } } @nogc

Re: cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote: Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } } template f(handlers...) { auto ref f(T)(auto ref T

Re: cannot use local __lambda1 as parameter to non-global template

2019-07-26 Thread aliak via Digitalmars-d-learn
On Friday, 26 July 2019 at 16:21:52 UTC, aliak wrote: On Friday, 26 July 2019 at 16:20:10 UTC, aliak wrote: Can someone help me understand the details around why this fails? import std; struct W(T) { T value; auto hook(handlers...)() { return handlers[0](value); } }

Re: How to check that import module will succeed?

2019-07-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: Is there a way to check whether some module, say "foo", is available for import before doing "import foo"? static if (is(typeof((){import that.module.here;}))) { // it is available }

Re: How to check that import module will succeed?

2019-07-26 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 26 July 2019 at 14:19:05 UTC, Paul Backus wrote: version(HasStdio) import std.stdio; else pragma(msg, "std.stdio is not available"); Then configure your build system to pass `-version=HasStdio` to dmd (or the equivalent flag to ldc or gdc) when std.stdio is available. I

Re: How to check that import module will succeed?

2019-07-26 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 26 July 2019 at 14:14:11 UTC, Anonymouse wrote: I use __traits(compiles, __traits(identifier, moduleName)) now instead and it seems to work. I couldn't find "identifier" docs on https://dlang.org/phobos/std_traits.html. But I tried and it doesn't work - I think because is unknown

Re: How to check that import module will succeed?

2019-07-26 Thread Andrey Zherikov via Digitalmars-d-learn
On Friday, 26 July 2019 at 06:24:18 UTC, evilrat wrote: On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: Is there a way to check whether some module, say "foo", is available for import before doing "import foo"? I did some really retarded utility like this in the past, worked

Re: How to check that import module will succeed?

2019-07-26 Thread Paul Backus via Digitalmars-d-learn
On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: Is there a way to check whether some module, say "foo", is available for import before doing "import foo"? I want to create a function that imports module if it's available or does something else otherwise. So I think the code

Re: How to check that import module will succeed?

2019-07-26 Thread Anonymouse via Digitalmars-d-learn
On Friday, 26 July 2019 at 06:24:18 UTC, evilrat wrote: On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: bool isModuleAvailable(alias modName)() { mixin("import " ~ modName ~ ";"); static if (__traits(compiles, mixin(modName).stringof)) return true;

Blog Post #0056: MVC IX - A ComboBox with Flair

2019-07-26 Thread Ron Tarrant via Digitalmars-d-learn
Today we get to do something unusual. Drawing on and combining a bunch of things we've done in past instalments, we'll build a two-column ComboBox with different images, custom fonts, and background colors for each item in the list. Here's the post:

Re: Is betterC affect to compile time?

2019-07-26 Thread Kagamin via Digitalmars-d-learn
On Thursday, 25 July 2019 at 12:46:48 UTC, Oleg B wrote: What reason for such restrictions? It's fundamental idea or temporary implementation? I think it's a dmd limitation. Currently it has a bug that it can still generate code for ctfe templated functions, and they will fail to link if

Re: How to check that import module will succeed?

2019-07-26 Thread evilrat via Digitalmars-d-learn
On Friday, 26 July 2019 at 03:42:58 UTC, Andrey Zherikov wrote: Is there a way to check whether some module, say "foo", is available for import before doing "import foo"? I did some really retarded utility like this in the past, worked for me, but I can't say it is that well tested and there