Concurrency and transfering "ownership" of data between threads?

2010-12-13 Thread Heywood Floyd
Good Evening from Berlin! Have been reading the chapter about concurrency by Andrei. Nice. I have some questions, of varying quality, I'm sure. Let's say that we have some sort of structure of rather complex data. To give us something concrete to talk about, let's say this data is a tree of n

Re: Comparing template alias parameters

2010-12-13 Thread Simen kjaeraas
Simen kjaeraas wrote: Given an index structure like this: struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) { private size_t idx; @property pure nothrow size_t get( ) const { return idx; } alias get this; invariant( ) { assert( idx < ar

Re: funny bug with input range interface and toString

2010-12-13 Thread Nick Voronin
On Mon, 13 Dec 2010 21:43:33 +0300, spir wrote: I use rdmd for quick testing (because it links automagically). compile: dmd -w -c filename.d build: rdmd -w -offilename" -debug -unittest --build-only filename.d Thanks. I missed -of option. -- Using Opera's revolutionary email client: http://w

Re: Removing an object from a range

2010-12-13 Thread Jesse Phillips
Andrej Mitrovic Wrote: > Does anyone know if there's any way I can get special highlighting for > lambda functions in say, Vim? It gets hard to distinguish between > regular parameters and one-liner lambdas, if I could change the > background color of a lambda it could really help out.. Off the t

Re: _indexed_ iteration using opApply or range

2010-12-13 Thread spir
On Mon, 13 Dec 2010 09:47:39 -0500 "Steven Schveighoffer" wrote: > What's wrong with using opApply? You should be able to define both range > primitives and opApply and opApply will be used when foreach is used, and > the range primitives will be used by things like std.algorithm. Hope opAp

Re: funny bug with input range interface and toString

2010-12-13 Thread spir
On Mon, 13 Dec 2010 17:37:19 +0300 "Nick Voronin" wrote: > On Mon, 13 Dec 2010 11:24:48 +0300, spir wrote: > > > I have a strange bug with an input range interface. Initially, I had a > > (rather big) struct called Text with loads of working unittests. When > > adding a range interface, not

Re: Removing an object from a range

2010-12-13 Thread Andrej Mitrovic
Does anyone know if there's any way I can get special highlighting for lambda functions in say, Vim? It gets hard to distinguish between regular parameters and one-liner lambdas, if I could change the background color of a lambda it could really help out.. On 12/13/10, Andrej Mitrovic wrote: > On

Re: Removing an object from a range

2010-12-13 Thread Andrej Mitrovic
On 12/13/10, Steven Schveighoffer wrote: > does this work? > Yes, ty. But I think there's a typo in std.algorithm.remove: Range remove(alias pred, SwapStrategy s = SwapStrategy.stable, Range)(Range range); Reduces the length of the bidirectional range range by only keeping elements that sati

Re: Removing an object from a range

2010-12-13 Thread spir
On Sun, 12 Dec 2010 20:43:12 -0500 "Andrej M." wrote: > I can't seem to find an easy remove method in std.algorithm that takes an > object and a range (an array in this case) and removes any matches from the > range. I'm using this snippet for now: > > private DrawingElement[] elements; > > p

Re: Removing an object from a range

2010-12-13 Thread Steven Schveighoffer
On Sun, 12 Dec 2010 20:43:12 -0500, Andrej M. wrote: I can't seem to find an easy remove method in std.algorithm that takes an object and a range (an array in this case) and removes any matches from the range. I'm using this snippet for now: private DrawingElement[] elements; public overr

Re: _indexed_ iteration using opApply or range

2010-12-13 Thread Steven Schveighoffer
On Sun, 12 Dec 2010 14:47:04 -0500, spir wrote: Hello, Had a nice time figuring out how to let opApply allow index iteration like: foreach (i, x ; collection) {} Finally managed to do it adding 'i' everywhere: struct S1 { private int[] elements = []; int opApply (int delegate (

Re: Facing problems with Class Properties

2010-12-13 Thread Steven Schveighoffer
On Fri, 10 Dec 2010 20:22:52 -0500, d coder wrote: Another thing, is(T : U) simply means T is implicitly castable to U. Due to a compiler bug, Bar[] is implicitly castable to BaseClass[]. Steve I realize that I am using this compiler bug as a feature. It would be kind of you to suggest m

Re: funny bug with input range interface and toString

2010-12-13 Thread Nick Voronin
On Mon, 13 Dec 2010 11:24:48 +0300, spir wrote: I have a strange bug with an input range interface. Initially, I had a (rather big) struct called Text with loads of working unittests. When adding a range interface, noting worked anymore, any test ran into an infinite loop (the terminal wri

Re: first shot for a combinator library for d

2010-12-13 Thread Christian Köstlin
thanks for your feedback! Maybe add support for predicated alternatives? what is this :) ? If you *really* want to make it more convenient, you could make a string mixin front for it, so that one could do something like mixin(maek_parser(" start -> s1 s2; s1 -> (`ab`|`cd`) `ef`; s2 -> (`1`

funny bug with input range interface and toString

2010-12-13 Thread spir
Hello, I have a strange bug with an input range interface. Initially, I had a (rather big) struct called Text with loads of working unittests. When adding a range interface, noting worked anymore, any test ran into an infinite loop (the terminal writes pages of '[') ending with segfault. After