howto run unittest of a single module in dub driven project?

2018-03-04 Thread Arjan via Digitalmars-d-learn
Is it somehow possible to only run the unittests of a single d file within a dub project? Of course without resorting to typing the complete commandline with all versions includes switches etc.

Re: howto run unittest of a single module in dub driven project?

2018-03-04 Thread Basile B. via Digitalmars-d-learn
On Sunday, 4 March 2018 at 10:43:06 UTC, Arjan wrote: Is it somehow possible to only run the unittests of a single d file within a dub project? Of course without resorting to typing the complete commandline with all versions includes switches etc. In Coedit yes. 1/ The path to the other

Template Class With Default Values

2018-03-04 Thread bauss via Digitalmars-d-learn
Why is the following not working? class Foo(string baz = "baz") { mixin("int " ~ baz ~ ";"); } class Bar : Foo { } Shouldn't it implicit do, without me having to do it manually? class Bar : Foo!"baz" { } ... What's the reason you can't specify default values for template parameters on

isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread aliak via Digitalmars-d-learn
Hi, I have a custom type D with front/popFront/empty implemented as free functions, but isInputRange returns false. I copied the implementation of isInputRange, and that custom implementation returns true... anyone know what's going on here? === import std.stdio, std.range, std.traits; //

Re: Template Class With Default Values

2018-03-04 Thread bauss via Digitalmars-d-learn
On Sunday, 4 March 2018 at 11:57:12 UTC, Jonathan M Davis wrote: On Sunday, March 04, 2018 11:35:23 bauss via Digitalmars-d-learn wrote: Why is the following not working? class Foo(string baz = "baz") { mixin("int " ~ baz ~ ";"); } class Bar : Foo { } Shouldn't it implicit do, without

Re: Template Class With Default Values

2018-03-04 Thread bauss via Digitalmars-d-learn
On Sunday, 4 March 2018 at 11:59:52 UTC, Mike Parker wrote: On Sunday, 4 March 2018 at 11:35:23 UTC, bauss wrote: Why is the following not working? class Foo(string baz = "baz") { mixin("int " ~ baz ~ ";"); } class Bar : Foo { } Shouldn't it implicit do, without me having to do it

Re: Template Class With Default Values

2018-03-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 04, 2018 11:35:23 bauss via Digitalmars-d-learn wrote: > Why is the following not working? > > class Foo(string baz = "baz") > { > mixin("int " ~ baz ~ ";"); > } > > class Bar : Foo > { > } > > Shouldn't it implicit do, without me having to do it manually? > > class Bar :

Re: Template Class With Default Values

2018-03-04 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 4 March 2018 at 11:35:23 UTC, bauss wrote: Why is the following not working? class Foo(string baz = "baz") { mixin("int " ~ baz ~ ";"); } class Bar : Foo { } Shouldn't it implicit do, without me having to do it manually? class Bar : Foo!"baz" { } class Bar : Foo!() { }

Re: howto run unittest of a single module in dub driven project?

2018-03-04 Thread Basile B. via Digitalmars-d-learn
On Sunday, 4 March 2018 at 11:38:37 UTC, Basile B. wrote: On Sunday, 4 March 2018 at 10:43:06 UTC, Arjan wrote: [...] In Coedit yes. 1/ The path to the other source (usually the path>/src/ or /source/) folder must be registered in the library manager. 2/ Menu "Compilation" item "Run file

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread aliak via Digitalmars-d-learn
On Sunday, 4 March 2018 at 13:17:30 UTC, Adam D. Ruppe wrote: On Sunday, 4 March 2018 at 12:57:41 UTC, aliak wrote: @property int front(D d) { return 2; } @property bool empty(D d) { return false; } void popFront(D d) {} Those functions are in scope for your function, but not inside

What's the proper way to add a local file dependence to dub?

2018-03-04 Thread Marc via Digitalmars-d-learn
then copy it to sources folder? let's say I have a small library folder at C:\mylibrary\D where I want to use dir.d from it. How do I add that file dependence to dub? But I do not want to that file be passed directly to dmd, I want to that file be copied to application's source folder (so

Re: howto run unittest of a single module in dub driven project?

2018-03-04 Thread Basile B. via Digitalmars-d-learn
On Sunday, 4 March 2018 at 12:22:35 UTC, Basile B. wrote: On Sunday, 4 March 2018 at 11:38:37 UTC, Basile B. wrote: On Sunday, 4 March 2018 at 10:43:06 UTC, Arjan wrote: [...] In Coedit yes. 1/ The path to the other source (usually the path>/src/ or /source/) folder must be registered in

Any crash reporter for D?

2018-03-04 Thread Marc via Digitalmars-d-learn
Does anyone knows about any crash repórter library for D? there's nothing I couldn't find at code packages. Something as simple and easy to use like this C#'s https://archive.codeplex.com/?p=crashreporterdotnet

Re: What's the proper way to add a local file dependence to dub?

2018-03-04 Thread bauss via Digitalmars-d-learn
On Sunday, 4 March 2018 at 16:46:56 UTC, Marc wrote: then copy it to sources folder? let's say I have a small library folder at C:\mylibrary\D where I want to use dir.d from it. How do I add that file dependence to dub? But I do not want to that file be passed directly to dmd, I want to that

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 4 March 2018 at 12:57:41 UTC, aliak wrote: @property int front(D d) { return 2; } @property bool empty(D d) { return false; } void popFront(D d) {} Those functions are in scope for your function, but not inside std.range. in other words std.range hasn't imported your module, so

Fastest way to zero a slice of memory

2018-03-04 Thread Nordlöw via Digitalmars-d-learn
When zeroing a slice of memory (either stack or heap) such as enum n = 100; ubyte[n] chunk; should I use `memset` such as memset(chunk.ptr, 0, n/2); // zero first half or an array assignment such as chunk[0 .. n/2] = 0; // zero first half or are they equivalent in release

Re: Fastest way to zero a slice of memory

2018-03-04 Thread bauss via Digitalmars-d-learn
On Sunday, 4 March 2018 at 15:23:41 UTC, Nordlöw wrote: When zeroing a slice of memory (either stack or heap) such as enum n = 100; ubyte[n] chunk; should I use `memset` such as memset(chunk.ptr, 0, n/2); // zero first half or an array assignment such as chunk[0 .. n/2] = 0;

Re: Template Class With Default Values

2018-03-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 04, 2018 14:43:41 bauss via Digitalmars-d-learn wrote: > On Sunday, 4 March 2018 at 11:57:12 UTC, Jonathan M Davis wrote: > > On Sunday, March 04, 2018 11:35:23 bauss via > > > > Digitalmars-d-learn wrote: > >> Why is the following not working? > >> > >> class Foo(string baz =

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 04, 2018 21:03:23 arturg via Digitalmars-d-learn wrote: > On Sunday, 4 March 2018 at 19:58:14 UTC, ag0aep6g wrote: > > On 03/04/2018 08:54 PM, aliak wrote: > >> wait a minute... so I can't use any std.range functions on a > >> type if I add the range primitives as free functions?

Re: Get function argument name?

2018-03-04 Thread JN via Digitalmars-d-learn
On Sunday, 4 March 2018 at 21:12:44 UTC, arturg wrote: you can pass it by alias: import std.stdio; void main(string[] args) { int x; printName!(x); } void printName(alias var)() { writeln(__traits(identifier, var), " ", var); } Well, it works. But I am confused now, why. Isn't

Re: Get function argument name?

2018-03-04 Thread bauss via Digitalmars-d-learn
On Sunday, 4 March 2018 at 21:48:53 UTC, JN wrote: On Sunday, 4 March 2018 at 21:12:44 UTC, arturg wrote: you can pass it by alias: import std.stdio; void main(string[] args) { int x; printName!(x); } void printName(alias var)() { writeln(__traits(identifier, var), " ", var); }

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread arturg via Digitalmars-d-learn
On Sunday, 4 March 2018 at 21:47:43 UTC, Jonathan M Davis wrote: On Sunday, March 04, 2018 21:03:23 arturg via Digitalmars-d-learn wrote: isn't this what DIP 1005 tried to solve? No. What DIP 1005 was trying to solve was avoiding having to have imports used by your function signature or

Re: importing std.array: empty in a struct messes things up

2018-03-04 Thread ag0aep6g via Digitalmars-d-learn
On 03/04/2018 08:17 PM, Dennis wrote: I was making a stack interface for an array: ``` struct Stack(T) {     import std.array: empty;     T[] stack;     alias stack this; } void main() {     Stack!int stack;     bool x = stack.empty; } ``` My expectation is that you can now call `empty` on

Re: Which Multithreading Solution?

2018-03-04 Thread Adam Wilson via Digitalmars-d-learn
On 3/4/18 11:31, Drew Phil wrote: Hey there! I'm trying to figure out which of D's many multithreading options to use for my application. I'm making a game that runs at 60 frames per second that can also run user-made Lua scripts. I would like to have the Lua scripts run in a separate thread so

Re: importing std.array: empty in a struct messes things up

2018-03-04 Thread arturg via Digitalmars-d-learn
On Sunday, 4 March 2018 at 20:07:06 UTC, visitor wrote: On Sunday, 4 March 2018 at 19:53:59 UTC, ag0aep6g wrote: On 03/04/2018 08:45 PM, ag0aep6g wrote: I don't know what's going on here. The error message doesn't make sense to me. Might be a bug in the compiler. This one works: struct

Get function argument name?

2018-03-04 Thread JN via Digitalmars-d-learn
Imagine a function like this: void printValue(T)(string name, T value) { writeln(name, " = ", value); } int x = 10; printValue("x", x); is it somehow possible to convert that printValue into a mixin or something, so I could do something like: printValue(x); and it will figure out the "x"

importing std.array: empty in a struct messes things up

2018-03-04 Thread Dennis via Digitalmars-d-learn
I was making a stack interface for an array: ``` struct Stack(T) { import std.array: empty; T[] stack; alias stack this; } void main() { Stack!int stack; bool x = stack.empty; } ``` My expectation is that you can now call `empty` on a stack instance since I imported it in

Which Multithreading Solution?

2018-03-04 Thread Drew Phil via Digitalmars-d-learn
Hey there! I'm trying to figure out which of D's many multithreading options to use for my application. I'm making a game that runs at 60 frames per second that can also run user-made Lua scripts. I would like to have the Lua scripts run in a separate thread so they can't delay frames if

Re: importing std.array: empty in a struct messes things up

2018-03-04 Thread ag0aep6g via Digitalmars-d-learn
On 03/04/2018 08:45 PM, ag0aep6g wrote: I don't know what's going on here. The error message doesn't make sense to me. Might be a bug in the compiler. This one works: struct Stack(T) { T[] stack; alias stack this; bool empty() {return empty(stack);} /* not using UFCS */

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread aliak via Digitalmars-d-learn
On Sunday, 4 March 2018 at 13:17:30 UTC, Adam D. Ruppe wrote: On Sunday, 4 March 2018 at 12:57:41 UTC, aliak wrote: @property int front(D d) { return 2; } @property bool empty(D d) { return false; } void popFront(D d) {} Those functions are in scope for your function, but not inside

Re: importing std.array: empty in a struct messes things up

2018-03-04 Thread arturg via Digitalmars-d-learn
I had the same issue, happens with any conflicting selective import. It seems to work if you dont use selective imports, but importing it inside the function if possible is a better option.

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread ag0aep6g via Digitalmars-d-learn
On 03/04/2018 08:54 PM, aliak wrote: wait a minute... so I can't use any std.range functions on a type if I add the range primitives as free functions? O.o Yes. In other words: You can't implement range primitives as free functions. Because std.range (and std.algorithm, etc.) doesn't know

Re: importing std.array: empty in a struct messes things up

2018-03-04 Thread visitor via Digitalmars-d-learn
On Sunday, 4 March 2018 at 19:53:59 UTC, ag0aep6g wrote: On 03/04/2018 08:45 PM, ag0aep6g wrote: I don't know what's going on here. The error message doesn't make sense to me. Might be a bug in the compiler. This one works: struct Stack(T) { T[] stack; alias stack this; bool

Re: isInputRange copied verbatim produces a different result than isInputRange from std.range

2018-03-04 Thread arturg via Digitalmars-d-learn
On Sunday, 4 March 2018 at 19:58:14 UTC, ag0aep6g wrote: On 03/04/2018 08:54 PM, aliak wrote: wait a minute... so I can't use any std.range functions on a type if I add the range primitives as free functions? O.o Yes. In other words: You can't implement range primitives as free functions.

Re: Get function argument name?

2018-03-04 Thread arturg via Digitalmars-d-learn
On Sunday, 4 March 2018 at 21:03:04 UTC, JN wrote: Imagine a function like this: void printValue(T)(string name, T value) { writeln(name, " = ", value); } int x = 10; printValue("x", x); is it somehow possible to convert that printValue into a mixin or something, so I could do something

Re: Get function argument name?

2018-03-04 Thread Timothee Cour via Digitalmars-d-learn
`printName(alias var)()` is not a great solution, eg: doesn't work with expressions, doesn't work with variadics, introduces template bloat. https://github.com/dlang/dmd/pull/7821 introduces __traits(getCallerSource, symbol) which will allow what you want. On Sun, Mar 4, 2018 at 1:53 PM, bauss

is it possible to put some DDOC after auto generated blocks like unittest examples?

2018-03-04 Thread arturg via Digitalmars-d-learn
/// void fun(){} ///$(TABLE $(TR $(TD Back to:) $(TD href="#fun">Declaration) $(TD $(LINK2 #top, Top unittest { } it basically should look like this: Declaration void fun() Example --- --- [Back to:] [Declaration] [Top] and if i replace the embbeded html with $(LINK2 #fun,

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (dmd v2.079.0, also

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: atan should work out to only be a few instructions (inline assembly) from what I've looked at in the source. Also you should post the code you used for each. Should be 3-4 instructions. Load input to the FPU (Optional?

Re: VibeD Rest Interface Generator

2018-03-04 Thread aberba via Digitalmars-d-learn
On Saturday, 3 March 2018 at 02:32:11 UTC, Mario wrote: So I've been learning D since the day 11 (I posted for first time here) and now I've decided to try Vibe.D to make my company API. The fact is that I've achieved to do it (according to the provided code) and it works! But it shows a

Re: Speed of math function atan: comparison D and C++

2018-03-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/03/2018 7:01 PM, J-S Caux wrote: On Monday, 5 March 2018 at 05:40:09 UTC, rikki cattermole wrote: On 05/03/2018 6:35 PM, J-S Caux wrote: I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared

Speed of math function atan: comparison D and C++

2018-03-04 Thread J-S Caux via Digitalmars-d-learn
I'm considering shifting a large existing C++ codebase into D (it's a scientific code making much use of functions like atan, log etc). I've compared the raw speed of atan between C++ (Apple LLVM version 7.3.0 (clang-703.0.29)) and D (dmd v2.079.0, also ldc2 1.7.0) by doing long loops of