Allocate an Array!T on the heap?

2012-06-21 Thread Tobias Pankrath
import std.container; struct A {}; void main() { Array!(A)* arr = new Array!(A); } yields bug.d(7): Error: template std.container.Array!(A).Array.__ctor does not match any function template declaration /usr/include/d/std/container.d(1625): Error: template std.container.Array!(A).Array._

Re: Object Cast

2012-06-21 Thread Kenji Hara
On Thursday, 21 June 2012 at 21:32:57 UTC, Namespace wrote: Works in dmd 2.059 too. Oh, good. [code] T template_cast(T : Object, U : Object)(U value) { // try to convert T val = cast(T) value; // if convert was successful, return if (val !is null) {

Re: sorting associative array's keys by values

2012-06-21 Thread Jonathan M Davis
On Monday, June 18, 2012 15:22:15 maarten van damme wrote: > and something I forgot to ask, is it a conscious decision to not print > out fired asserts in treads? Normally when an assert fails my whole > program crashes and I can see what went wrong. With treads however, it > quietly dies. It coul

Re: how to handle shared arrays?

2012-06-21 Thread Jonathan M Davis
On Thursday, June 21, 2012 21:00:32 maarten van damme wrote: > I want to have two threads. One parses some content ever half hour and > the other continuously parses commands passed from the first thread. > When the second thread finished something it should send the results > back to the first thr

Re: how to handle shared arrays?

2012-06-21 Thread Ali Çehreli
On 06/21/2012 02:30 PM, maarten van damme wrote: > Oh thank god, this helps soo much. Yay! :) Thinking more about it, assumeUnique is a more general solution which may not be needed in every case. As long as the worker is happy with an immutable(Result) slice, the following delegate works as w

Re: Object Cast

2012-06-21 Thread Namespace
Works in dmd 2.059 too. [code] T template_cast(T : Object, U : Object)(U value) { // try to convert T val = cast(T) value; // if convert was successful, return if (val !is null) { return val; } // if cast fails it

Re: how to handle shared arrays?

2012-06-21 Thread maarten van damme
Oh thank god, this helps soo much. Now I can finally do away with all those ugly shared casts and variables in my other toy code involving threads. It works like a charm, great.

Re: how to handle shared arrays?

2012-06-21 Thread Ali Çehreli
On 06/21/2012 12:00 PM, maarten van damme wrote: > I want to have two threads. One parses some content ever half hour and > the other continuously parses commands passed from the first thread. > When the second thread finished something it should send the results > back to the first thread who'll

Re: filename.writeln() across network

2012-06-21 Thread Danny Arends
On Thursday, 21 June 2012 at 17:14:34 UTC, Regan Heath wrote: On Thu, 21 Jun 2012 14:56:37 +0100, Paul wrote: I wrote a program that parses a text file and writes results as it is processing the file (i.e. many writeln()'s). On my local harddrive it works fine. When I later used it on a fi

how to handle shared arrays?

2012-06-21 Thread maarten van damme
I want to have two threads. One parses some content ever half hour and the other continuously parses commands passed from the first thread. When the second thread finished something it should send the results back to the first thread who'll present it to the user. The messages the second thread nee

Re: filename.writeln() across network

2012-06-21 Thread Jonathan M Davis
On Thursday, June 21, 2012 18:14:26 Regan Heath wrote: > On Thu, 21 Jun 2012 14:56:37 +0100, Paul wrote: > > I wrote a program that parses a text file and writes results as it is > > processing the file (i.e. many writeln()'s). On my local harddrive it > > works fine. When I later used it on a fil

Re: filename.writeln() across network

2012-06-21 Thread Regan Heath
On Thu, 21 Jun 2012 14:56:37 +0100, Paul wrote: I wrote a program that parses a text file and writes results as it is processing the file (i.e. many writeln()'s). On my local harddrive it works fine. When I later used it on a file located on a file server, it went from 500ms to 1 minute

Re: Lack of warning messages

2012-06-21 Thread Trass3r
A notice for some unused imports would be great too... You could create a brute-force tool. Rip off an import statement at a time and see if it still compiles. One could probably modify DustMite to do that.

Re: Lack of warning messages

2012-06-21 Thread Namespace
A notice for some unused imports would be great too...

Re: Lack of warning messages

2012-06-21 Thread bearophile
IK: Even if I use the -w and -wi flags I don't get warnings for unused variables. How to enable extra warnings? Please vote :-) http://d.puremagic.com/issues/show_bug.cgi?id=3960 http://d.puremagic.com/issues/show_bug.cgi?id=4694 http://d.puremagic.com/issues/show_bug.cgi?id=6449 Asking agai

Re: Lack of warning messages

2012-06-21 Thread simendsjo
On Thu, 21 Jun 2012 16:25:45 +0200, IK wrote: Even if I use the -w and -wi flags I don't get warnings for unused variables. How to enable extra warnings? You don't get more warnings than -w unfortunately.

Lack of warning messages

2012-06-21 Thread IK
Even if I use the -w and -wi flags I don't get warnings for unused variables. How to enable extra warnings?

Re: Object Cast

2012-06-21 Thread Kenji Hara
On Thursday, 21 June 2012 at 10:33:41 UTC, Namespace wrote: To solve the problem of converting a Object to a specific template class i wrote this little function. But the mixin disturbs me. How i can get the type (in this example Vector2D) without to mix a mixin and T.stringof? [code] T object

filename.writeln() across network

2012-06-21 Thread Paul
I wrote a program that parses a text file and writes results as it is processing the file (i.e. many writeln()'s). On my local harddrive it works fine. When I later used it on a file located on a file server, it went from 500ms to 1 minute processing time. It there a more efficient way to wr

Object Cast

2012-06-21 Thread Namespace
To solve the problem of converting a Object to a specific template class i wrote this little function. But the mixin disturbs me. How i can get the type (in this example Vector2D) without to mix a mixin and T.stringof? [code] T object_cast(T : Object)(Object value) { T val = cast(T) val

Re: How use "toHash" without cast

2012-06-21 Thread Namespace
I see, a bit confusing but I think I understand. Thank you. :)

Re: Array/list of objects of different type but with same interface

2012-06-21 Thread Joseph Rushton Wakeling
On 20/06/12 23:00, bearophile wrote: std.variant.Algebraic? Interesting thought. I fear it's a no-go as you'd have to specify up-front all the possible agent choices, but I'll have a play ... Thanks very much! :-)

Re: How use "toHash" without cast

2012-06-21 Thread Jonathan M Davis
On Thursday, June 21, 2012 09:48:52 Namespace wrote: > > It's actually @trusted as per the docs. I do not know why DMD > > infers that to be @safe. > > > > In any case, the solution here is this: > > override hash_t toHash() @trusted const pure nothrow { > > > > return cast(ha

Re: How use "toHash" without cast

2012-06-21 Thread Namespace
It's actually @trusted as per the docs. I do not know why DMD infers that to be @safe. In any case, the solution here is this: override hash_t toHash() @trusted const pure nothrow { return cast(hash_t)(this.x + this.y); } Yes, it's already trusted. If I write "@trusted co