Re: static initialization of structs

2012-12-01 Thread Dan
On Sunday, 2 December 2012 at 01:50:08 UTC, Jonathan M Davis wrote: On Saturday, December 01, 2012 19:36:34 Dan wrote: That syntax is from C. There was definitely a push to deprecate it, and personally I definitely think that it should go, but I don't recall that it was definitively decided t

Re: static initialization of structs

2012-12-01 Thread Jonathan M Davis
On Saturday, December 01, 2012 19:36:34 Dan wrote: > In the thread on compiling DSSS and build tools someone mentioned > a format for initializing environment data of a struct: > >Environment env = { > tests: true, > verbose: true, > importDirs: ["../deimos"] >} >

Re: DLL Injection

2012-12-01 Thread s0beit
Alright, I was finally able to give it a try: http://s0beit.me/d/d-module-injector/ I released the source code as well as the binary here if anyone wants to try. It worked for me in a game I was playing with.

Re: get address of object if opCast is overridden

2012-12-01 Thread Jonathan M Davis
On Sunday, December 02, 2012 00:57:14 Artur Skawina wrote: > Seriously though, if one only needs to compare the addresses of class > objects, "is" may be a better solution. Is that all that was being done? I obviously missed that one way or another. Yeah, that's what the is operator is for. - Jo

Re: get address of object if opCast is overridden

2012-12-01 Thread Artur Skawina
On 12/01/12 20:26, Jonathan M Davis wrote: > On Saturday, December 01, 2012 18:43:22 Timon Gehr wrote: >> On 12/01/2012 06:23 PM, Jonathan M Davis wrote: >>> On Saturday, December 01, 2012 12:05:49 Artur Skawina wrote: > So, unless there's a way to do it without a cast, you're stuck. And I

Re: alias this

2012-12-01 Thread Rob T
On Saturday, 1 December 2012 at 21:33:15 UTC, js.mdnq wrote: By full signature overloading I assuming you also the return type? Correct. I don't see why it is so complicated in any case since a return type can just be seen as a ref argument: int myfunc() is basically the same as void

Re: alias this

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 20:25:55 UTC, Rob T wrote: On Friday, 30 November 2012 at 23:11:28 UTC, js.mdnq wrote: I've seen that, how does it work? struct A{ Sometype val1; int val2; alias val1 this; alias val2 this; //??? } How can A act both as Sometype and int? (at least without maj

Re: static initialization of structs

2012-12-01 Thread Rob T
On Saturday, 1 December 2012 at 18:36:35 UTC, Dan wrote: In the thread on compiling DSSS and build tools someone mentioned a format for initializing environment data of a struct: Environment env = { tests: true, verbose: true, importDirs: ["../deimos"] } A followup co

Re: struct initialization and assignment by field name

2012-12-01 Thread Rob T
On Saturday, 1 December 2012 at 19:32:27 UTC, bearophile wrote: I don't know the rationale. There are tons of things I don't know the rationale of, despite my efforts to learn. The normal way to write a struct literal in D is this, that works in most cases: auto foo = MyStruct(42, 'a'); A

Re: alias this

2012-12-01 Thread Rob T
On Friday, 30 November 2012 at 23:11:28 UTC, js.mdnq wrote: I've seen that, how does it work? struct A{ Sometype val1; int val2; alias val1 this; alias val2 this; //??? } How can A act both as Sometype and int? (at least without major issues) Does the compiler try to choose the appropria

Re: Apparent problem with GC not collecting on Windows

2012-12-01 Thread Dmitry Olshansky
12/1/2012 10:46 PM, thedeemon пишет: On Saturday, 1 December 2012 at 12:55:19 UTC, Dmitry Olshansky wrote: It should help because: 1) Each allocation happens in a new stack frame thus the pointer is overwritten each time. To probably the same stinky value (a false pointer). Pointer is differ

Re: struct initialization and assignment by field name

2012-12-01 Thread bearophile
Bobby Bingham: It appears that this form of struct literal really can only be used in initializers -- the assignment to a previously declared varaible fails to compile. Right. That syntax is not much used in D, there were discussions about deprecating it fully, I don't know the current statu

Re: get address of object if opCast is overridden

2012-12-01 Thread Jonathan M Davis
On Saturday, December 01, 2012 18:43:22 Timon Gehr wrote: > On 12/01/2012 06:23 PM, Jonathan M Davis wrote: > > On Saturday, December 01, 2012 12:05:49 Artur Skawina wrote: > >>> So, unless there's a way to do it without a cast, you're stuck. And I > >>> have > >>> no idea how you could possibly do

struct initialization and assignment by field name

2012-12-01 Thread Bobby Bingham
I'm just starting out with D, and am wondering about some differences with C regarding struct literals. In C99, I can do this: struct MyStruct { int number; char letter; }; int main() { static struct MyStruct foo = { .number = 42, .letter = 'a' }; struct MyStruct bar = { .number

Re: Apparent problem with GC not collecting on Windows

2012-12-01 Thread thedeemon
On Saturday, 1 December 2012 at 12:55:19 UTC, Dmitry Olshansky wrote: It should help because: 1) Each allocation happens in a new stack frame thus the pointer is overwritten each time. To probably the same stinky value (a false pointer). 2) Precise heap scanning helps this case because it gre

static initialization of structs

2012-12-01 Thread Dan
In the thread on compiling DSSS and build tools someone mentioned a format for initializing environment data of a struct: Environment env = { tests: true, verbose: true, importDirs: ["../deimos"] } A followup comment says "isn't that syntax intended to be deprecated?"

Re: DLL Injection

2012-12-01 Thread s0beit
On Saturday, 1 December 2012 at 12:29:51 UTC, js.mdnq wrote: On Saturday, 1 December 2012 at 11:24:51 UTC, s0beit wrote: Alright, at the end of my long search I have finally concluded that this is some sort of threading problem. Any D module loaded in a new thread, from a C/++ application wil

Re: get address of object if opCast is overridden

2012-12-01 Thread Timon Gehr
On 12/01/2012 06:23 PM, Jonathan M Davis wrote: On Saturday, December 01, 2012 12:05:49 Artur Skawina wrote: So, unless there's a way to do it without a cast, you're stuck. And I have no idea how you could possibly do it without a cast. *cast(void**)&O // assuming O is a class Are you su

Re: get address of object if opCast is overridden

2012-12-01 Thread Jonathan M Davis
On Saturday, December 01, 2012 12:05:49 Artur Skawina wrote: > > So, unless there's a way to do it without a cast, you're stuck. And I have > > no idea how you could possibly do it without a cast. > >*cast(void**)&O // assuming O is a class Are you sure? I'd be _very_ wary of that, because re

Re: How works internally ParallelForEach

2012-12-01 Thread jerro
On Saturday, 1 December 2012 at 12:51:27 UTC, thedeemon wrote: On Saturday, 1 December 2012 at 11:36:16 UTC, Zardoz wrote: The prevois code should work better if i set "total" to be sahred and hope that D shared vars have nnow the internal barries working ,or I need to manually use semaphores

Re: Apparent problem with GC not collecting on Windows

2012-12-01 Thread Dmitry Olshansky
12/1/2012 2:53 PM, thedeemon пишет: On Friday, 30 November 2012 at 18:46:08 UTC, Dmitry Olshansky wrote: I'd just throw in that we have a (almost) precise GC that is used by at least one large project (the VisualD apparently). Though there were some problems with it. Anyway I'd expect to see it

Re: How works internally ParallelForEach

2012-12-01 Thread thedeemon
On Saturday, 1 December 2012 at 11:36:16 UTC, Zardoz wrote: The prevois code should work better if i set "total" to be sahred and hope that D shared vars have nnow the internal barries working ,or I need to manually use semaphores ? Probably core.atomic is the way to go. Semaphore is an overk

Re: get address of object if opCast is overridden

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 11:06:02 UTC, Artur Skawina wrote: On 12/01/12 03:48, Jonathan M Davis wrote: On Saturday, December 01, 2012 03:05:00 js.mdnq wrote: Let O be an object with opCast overridden, then writeln(O); //prints string writeln(cast(void *)O)) // error, works fine if I co

Re: DLL Injection

2012-12-01 Thread js.mdnq
On Saturday, 1 December 2012 at 11:24:51 UTC, s0beit wrote: Alright, at the end of my long search I have finally concluded that this is some sort of threading problem. Any D module loaded in a new thread, from a C/++ application will crash. The solution, I believe, in this case might be to hi

Re: How works internally ParallelForEach

2012-12-01 Thread Zardoz
On Saturday, 1 December 2012 at 10:58:55 UTC, thedeemon wrote: taskPool.parallel is a library function, it doesn't make compiler smarter and doesn't get much help from the compiler. It means your "total" variable will not get any special treatment, it's still a local variable referenced from

Re: DLL Injection

2012-12-01 Thread s0beit
Alright, at the end of my long search I have finally concluded that this is some sort of threading problem. Any D module loaded in a new thread, from a C/++ application will crash. The solution, I believe, in this case might be to hijack the program's "main" thread and execute your LoadLibrary

Re: get address of object if opCast is overridden

2012-12-01 Thread Artur Skawina
On 12/01/12 03:48, Jonathan M Davis wrote: > On Saturday, December 01, 2012 03:05:00 js.mdnq wrote: >> Let O be an object with opCast overridden, then >> >> >> writeln(O); //prints string >> writeln(cast(void *)O)) // error, works fine if I comment out the >> opCast override >> writeln(&O) // addre

Re: How works internally ParallelForEach

2012-12-01 Thread thedeemon
On Saturday, 1 December 2012 at 10:35:38 UTC, Zardoz wrote: auto logs = new double[10_000_000]; double total = 0; foreach(i, ref elem; taskPool.parallel(logs, 100)) { elem = log(i + 1.0); total += elem; } writeln(total); } I understand that are launched N task, doing a chunk o

Re: Apparent problem with GC not collecting on Windows

2012-12-01 Thread thedeemon
On Friday, 30 November 2012 at 18:46:08 UTC, Dmitry Olshansky wrote: I'd just throw in that we have a (almost) precise GC that is used by at least one large project (the VisualD apparently). Though there were some problems with it. Anyway I'd expect to see it in upstream by 2.062 at least. I

How works internally ParallelForEach

2012-12-01 Thread Zardoz
How works internally ParallelFor ? I read that lauchn multiple tasks. Each task procces a chunk of the range, but each task it's syncronized , ahve some kind of comunication between or are using shared memory or what ?? In this example code : import std.stdio; import std.parallelism; import st