Re: linked list

2010-09-27 Thread Denis Koroskin
On Mon, 27 Sep 2010 10:27:36 +0400, Joel Christensen wrote: Thanks for the long winded reply Jonathan. I don't know how to avoid using my own linked list, I have next/prev in each class (Ball, Lazer and Mine ) in the list. That's called intrusive linked list, and I find using it quite

Re: Segmentation fault on closing file in destructor

2010-09-27 Thread Lars T. Kyllingstad
On Sun, 26 Sep 2010 20:55:33 +0200, Tom Kazimiers wrote: > If I would use std.stdio.File, what would be different? Well, for one thing you won't have to write your code all over again when std.stream is deprecated, which will happen soon. std.stdio.File is really what you should use for file I/

Re: linked list, ranges

2010-09-27 Thread Steven Schveighoffer
On Sun, 26 Sep 2010 04:38:36 -0400, Joel Christensen wrote: Thanks again for the reply Jonathan. I'm using doublely linked list I made for a game where ships and there lazer bolts are in the same list. Without linked list I couldn't do things like create a lazer bolt or remove one while

Re: Segmentation fault on closing file in destructor

2010-09-27 Thread Steven Schveighoffer
On Sun, 26 Sep 2010 20:20:18 -0400, Michel Fortin wrote: On 2010-09-26 10:06:33 -0400, "Simen kjaeraas" said: Tom Kazimiers <2voo...@gmx.de> wrote: Hi, a file reading class of mine can be constructed with a filename as parameter. It instantiates a new std.stream.File (without the pass

Re: Segmentation fault on closing file in destructor

2010-09-27 Thread Steven Schveighoffer
On Sun, 26 Sep 2010 11:17:07 -0400, Tom Kazimiers <2voo...@gmx.de> wrote: Hi Simen, On 09/26/2010 04:06 PM, Simen kjaeraas wrote: Likely, it is this[1]: "[T]he order in which the garbage collector calls destructors for unreference objects is not specified. This means that when the garbage col

dcollection docs

2010-09-27 Thread Johannes Pfau
On 27.09.2010 14:01, Steven Schveighoffer wrote: > > > Sorry about lack of online docs, I need to figure out how to > automatically generate them (the D1 docs are auto-generated, but I > haven't put in any time to figure out how to generate the D2 version). > > -Steve Yao has a nice ddoc templa

Re: dcollection docs

2010-09-27 Thread Steven Schveighoffer
On Mon, 27 Sep 2010 08:34:57 -0400, Johannes Pfau wrote: On 27.09.2010 14:01, Steven Schveighoffer wrote: Sorry about lack of online docs, I need to figure out how to automatically generate them (the D1 docs are auto-generated, but I haven't put in any time to figure out how to generate the

Dispatching from receive to a function

2010-09-27 Thread Bob Cowdery
I've been looking for a way to hook up messages to a thread with a handler function. As far as I can tell receive pattern matching only allows the pattern to be distinguished by the parameter signature which does not help when all the handlers only have a few different signatures. I like the patt

Re: Dispatching from receive to a function

2010-09-27 Thread Johannes Pfau
On 27.09.2010 15:07, Bob Cowdery wrote: > > Failing that I think a dispatcher structure using an associative array > would be my next choice. However I'm getting stuck on how to define and > use an array which maps a string key to a delegate. Can someone help me > out there please. I will then eff

Re: Dispatching from receive to a function

2010-09-27 Thread Bob Cowdery
Thanks. Do you know if the signature is a mandatory part. If I left the signature out would it then only work with a delegate with no parameters? If so I think I'm in the same state as my delegates will not all have the same signature. Bob On 27/09/2010 14:21, Johannes Pfau wrote: > On 27.09.201

Re: Dispatching from receive to a function

2010-09-27 Thread Johannes Pfau
On 27.09.2010 15:36, Bob Cowdery wrote: > Thanks. Do you know if the signature is a mandatory part. If I left the > signature out would it then only work with a delegate with no > parameters? If so I think I'm in the same state as my delegates will not > all have the same signature. > Yep, the s

Re: Dispatching from receive to a function

2010-09-27 Thread Juanjo Alvarez
I'm new to the language so I don't know if this is horribly wrong on some levels, but it works: - import std.variant; import std.stdio; class C { bool test(int i, char c) { writeln("Hello from test1"); return true; } void test2(string v) { writeln("Hello from

Re: Dispatching from receive to a function

2010-09-27 Thread Johannes Pfau
On 27.09.2010 20:46, Juanjo Alvarez wrote: > I'm new to the language so I don't know if this is horribly wrong on some > levels, but it works: > > - > > import std.variant; > import std.stdio; > > class C > { > bool test(int i, char c) { writeln("Hello from test1

Re: Dispatching from receive to a function

2010-09-27 Thread Juanjo Alvarez
On Mon, 27 Sep 2010 21:00:48 +0200, Johannes Pfau wrote: > On 27.09.2010 20:46, Juanjo Alvarez wrote: >> I'm new to the language so I don't know if this is horribly wrong on >> some levels, but it works: >> >> - >> >> import std.variant; >> import std.stdio; >> >> cl

Re: dcollection docs

2010-09-27 Thread Yao G.
On Mon, 27 Sep 2010 07:34:57 -0500, Johannes Pfau wrote: Yao has a nice ddoc template for D2. See for example http://d.yao.com.mx/datetime/core.html The ddoc file is available here: https://bitbucket.org/gomez/yao-library/src/da11956a6a6e/docs/ but I don't know about the license for that file,

Re: dcollection docs

2010-09-27 Thread Yao G.
On Mon, 27 Sep 2010 07:46:49 -0500, Steven Schveighoffer wrote: Thanks, Yao's seems similar to Phobos, which I'm not a big fan of. Particularly the munged-together list of constructs/functions at the top. To be honest, I don't like it either :) I plan to improve it, and by improve it

Re: Dispatching from receive to a function

2010-09-27 Thread Bob Cowdery
Thanks for the suggestions. I'm still hankering after an elegant solution to the receive rather than try to patch it up after the event. The best I can come up with is pretty ugly (odd) at the front but looks better at the back-end. Maybe someone can refine it a bit. struct RATE{}; struct SRC_1{

Re: Dispatching from receive to a function

2010-09-27 Thread Philippe Sigaud
On Mon, Sep 27, 2010 at 21:49, Juanjo Alvarez < juan...@thatwebmailofgoogleproperty.com> wrote: > >> Curiously if you create holder like this, it will give an > >> arrayoutofbound error at runtime, I don't know if that is a bug: > I think I got this one too. IIRC, it's a bug in the holder["test"]

Re: intrusive linked list

2010-09-27 Thread Joel Christensen
That's called intrusive linked list, and I find using it quite viable: zero-allocation O(1) add/removal is a very strong characteristics. They are very useful especially for lock-free algorithms. That's for the info Denis. I got the idea from a friend who is interested in how to make games.