Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn
On 23.04.2016 03:11, Ramon wrote: mmm, I figured the problem, but don't know how to solve it. my struct has a destructor which clears itself: struct json_value { ~this() { .ValueClear(); } } So the struct is destroyed at the end of DoDirSearch, despite there being a closure for it. Is the

Re: How do you use D to launch/open a window?

2016-04-22 Thread rikki cattermole via Digitalmars-d-learn
On 23/04/2016 9:29 AM, anonymousuer wrote: On Friday, 22 April 2016 at 21:26:25 UTC, ciechowoj wrote: On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote: What code is needed to tell D to open a window? Thank you in advance. Could you specify what kind of window do you need? As in

Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread ed via Digitalmars-d-learn
On Saturday, 23 April 2016 at 01:11:49 UTC, Ramon wrote: mmm, I figured the problem, but don't know how to solve it. my struct has a destructor which clears itself: struct json_value { ~this() { .ValueClear(); } } so how I can I put a struct in the heap? (not in the stack, as is the

Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread Ramon via Digitalmars-d-learn
mmm, I figured the problem, but don't know how to solve it. my struct has a destructor which clears itself: struct json_value { ~this() { .ValueClear(); } } so how I can I put a struct in the heap? (not in the stack, as is the default..)

Are structs saved in multi-thread delegate call?

2016-04-22 Thread Ramon via Digitalmars-d-learn
I have something along this way: struct json_value { .. } function DoDirSearch(..) { immutable json_value cbk = json_value(prms.argv[3]); assert(cbk != json_value.init); // OK, pass import core.thread; new Thread({ assert(cbk !=

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread rcorre via Digitalmars-d-learn
On Friday, 22 April 2016 at 10:25:34 UTC, Chris wrote: On Friday, 22 April 2016 at 09:49:02 UTC, Rene Zwanenburg wrote: On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote: - What happens when you compile a binary without phobos and druntime, and with a custom entry point? I've never done

Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote: Have anybody implement Ada-style modulo types https://en.wikibooks.org/wiki/Ada_Programming/Types/mod I've implemented a proof-of-concept for algorithmic programming competitions [1]. In these competitions, quite a few problems ask to

std.experimental.allocator example wanted

2016-04-22 Thread Danni Coy via Digitalmars-d-learn
Can somebody give me a quick example of how to combine the MMapAllocator with the AllocatorList and the BitmapBlock objects together?

Re: How do you use D to launch/open a window?

2016-04-22 Thread anonymousuer via Digitalmars-d-learn
On Friday, 22 April 2016 at 21:26:25 UTC, ciechowoj wrote: On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote: What code is needed to tell D to open a window? Thank you in advance. Could you specify what kind of window do you need? As in a regular Windows window, for example when

Re: How do you use D to launch/open a window?

2016-04-22 Thread ciechowoj via Digitalmars-d-learn
On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote: What code is needed to tell D to open a window? Thank you in advance. Could you specify what kind of window do you need?

How do you use D to launch/open a window?

2016-04-22 Thread anonymousuer via Digitalmars-d-learn
What code is needed to tell D to open a window? Thank you in advance.

Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Timon Gehr via Digitalmars-d-learn
On 22.04.2016 21:52, Nordlöw wrote: On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote: Have anybody implement Ada-style modulo types https://en.wikibooks.org/wiki/Ada_Programming/Types/mod Here's my first try https://github.com/nordlow/phobos-next/blob/master/src/modulo.d Is there a

Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Nordlöw via Digitalmars-d-learn
On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote: Have anybody implement Ada-style modulo types https://en.wikibooks.org/wiki/Ada_Programming/Types/mod Here's my first try https://github.com/nordlow/phobos-next/blob/master/src/modulo.d Is there a way to use alias _value this;

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread David Nadlinger via Digitalmars-d-learn
On Thursday, 21 April 2016 at 14:47:55 UTC, Nick Treleaven wrote: I found std.meta.ApplyLeft but it doesn't seem to work here. I've needed this before and ended up doing a workaround with a template block and temporary alias but it might be nice if Phobos had this. Or is there a simpler

Re: Enabling Only Top-Level Unittests

2016-04-22 Thread Basile B. via Digitalmars-d-learn
On Thursday, 21 April 2016 at 19:38:21 UTC, Nordlöw wrote: On Thursday, 21 April 2016 at 12:35:42 UTC, Anonymouse wrote: Then dmd -unittest -version=TestDeps if you want them run. This doesn't make things easier. I want to disable the builtin unittests of the modules I've imported. This

Ada-Style Modulo Integer Types

2016-04-22 Thread Nordlöw via Digitalmars-d-learn
Have anybody implement Ada-style modulo types https://en.wikibooks.org/wiki/Ada_Programming/Types/mod in D? I'm thinking modulo.d: struct Mod(size_t m, Block = uint) { static assert(m <= 2^^(8*Block.sizeof)); Block value; } typically used as Mod!(8, ubyte) Mod!(256, ubyte) Mod!(8,

Re: VisualD + ZeroMQ

2016-04-22 Thread Chuck Moore via Digitalmars-d-learn
On Thursday, 21 April 2016 at 00:15:03 UTC, Chuck Moore wrote: Hi Everyone, Preamble: We're a Win7+VisualStudio development environment. This question involves integrating the GitHub-based . Chuck Hi Everyone, I finally got my compilation+linking to work using VisualD. In the event

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn
On 22/04/2016 14:40, Steven Schveighoffer wrote: OK, I get it. I think this used to work, but I think D has long since disallowed direct access to eponymous members. So what you really want to do is: staticEx!(Exception, msg)!(file, line), but of course this doesn't follow proper grammar. I

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/22/16 6:50 AM, Nick Treleaven wrote: On 21/04/2016 18:03, Steven Schveighoffer wrote: This doesn't work? alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = staticEx!(Exception, msg).staticEx!(file, line); No, nor using the module dot prefix `=

Re: "inline" conversion of array to immutable

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn
On 22.04.2016 13:46, Jeff Thompson wrote: The function literal also works if I add "function int[]()": void main(string[] args) { immutable int[] array = function int[]() { int[] result = new int[10]; result[0] = 1; return result; }(); } I take it you're on 2.070 or older

Re: "inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn
On Friday, 22 April 2016 at 11:16:59 UTC, ag0aep6g wrote: It's a nested function now. That means, it could reference local variables of main. Make func static and it works. You can also use a function literal: void main() { immutable int[] array = { int[] result = new int[10];

Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn
On Friday, 22 April 2016 at 11:07:47 UTC, Jeff Thompson wrote: On Friday, 22 April 2016 at 09:40:14 UTC, FreeSlave wrote: On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote: Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable

Re: "inline" conversion of array to immutable

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn
On 22.04.2016 13:07, Jeff Thompson wrote: OK, we lose the compiler check for correctness. What if I put func directly in main with the hopes that the compiler will check correctness and also inline the function? But it won't assign to the immutable array. Why not? It's the same function. void

Re: aliasing/referencing expressions in with statements

2016-04-22 Thread deed via Digitalmars-d-learn
On Friday, 22 April 2016 at 01:42:11 UTC, Yuxuan Shui wrote: Maybe use something like: auto a = () => instanceA.verboseFieldA.verboseFieldB; You can certainly declare temporaries and rely on the compiler optimizing those away: auto a = instanceA.verboseFieldA.verboseFieldB; auto b =

Re: "inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn
On Friday, 22 April 2016 at 09:40:14 UTC, FreeSlave wrote: On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote: Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable variable: [...] Probably this is what you look for

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn
On 21/04/2016 18:03, Steven Schveighoffer wrote: This doesn't work? alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = staticEx!(Exception, msg).staticEx!(file, line); No, nor using the module dot prefix `= .staticEx!(...).staticEx` either: staticex.d(3): Error:

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Chris via Digitalmars-d-learn
On Friday, 22 April 2016 at 09:49:02 UTC, Rene Zwanenburg wrote: On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote: - What happens when you compile a binary without phobos and druntime, and with a custom entry point? I've never done that myself and don't remember how to do that off the

Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote: - What happens when you compile a binary without phobos and druntime, and with a custom entry point? I've never done that myself and don't remember how to do that off the top of my head, but the info should be somewhere on dlang.org.

Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn
On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote: Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable variable: [...] Probably this is what you look for http://dlang.org/phobos/std_exception.html#.assumeUnique

Re: Whitch can replace std::bind/boost::bind ?

2016-04-22 Thread Dsby via Digitalmars-d-learn
On Friday, 18 March 2016 at 17:24:27 UTC, Ali Çehreli wrote: On 03/18/2016 03:50 AM, Dsby wrote: foreach (i ; 0..4) { auto th = new Thread(delegate(){listRun(i);});//this is erro _thread[i]= th; th.start(); } void listRun(int i) { writeln("i = ", i); // the value is

"inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn
Hello. The following code compiles OK where func creates a mutable array and main assigns it to an immutable variable: int[] func(int x) pure { int[] result = new int[10]; result[0] = x; return result; } void main(string[] args) { immutable int[] array = func(1); } I assume this works

Re: GC allocation

2016-04-22 Thread Alex via Digitalmars-d-learn
On Friday, 22 April 2016 at 01:55:36 UTC, Adam D. Ruppe wrote: On Thursday, 21 April 2016 at 22:59:58 UTC, Alex wrote: Ok... I make slices of them, carefully avoiding to make copies... Yeah, that shouldn't make a difference.. Wait, wait... I try to make slices of the array of delegates,