std.concurrency, or me?

2011-01-10 Thread Jesse Phillips
Reddit let me to this article walking through an example of Goroutines[1]. I figured it could look about the same in D. So I set out to learn some multi-threading. And what I ended up with[2] had an issue. The mailbox size seems to be extremely small. Currently I have set the size to 10,000 and

Re: Templated delegate

2011-01-10 Thread Mitja
Stewart Gordon Wrote: > On 10/01/2011 13:02, Mitja wrote: > > I would like to have a template which returns > > appropriate delegate, something like this: > > For what purpose? All you seem to have is a long-winded identity function. > > > > and compiled it like this: dmd mod2.d mod1.d, the pr

Re: Templated delegate

2011-01-10 Thread Mitja
Thanks, toDelegate is what I've been looking for. It still segfaults, though. The setup: === module mod1; import std.algorithm; import std.functional; import std.stdio; void main( ) { auto haystack = ["a","b","c"]; auto needle = "b"; auto flt = delegate(string s){return s == needle;

Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Mon, 10 Jan 2011 08:38:15 -0800, Dan Olson wrote: > "Lars T. Kyllingstad" writes: > >> On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote: >> >>> I'm exploring D for embedded work as a nice alternative to C/C++ for >>> the 32-bitters and am finding it has a nice set of features. But, >>> wh

Re: Memory mapped IO

2011-01-10 Thread Dan Olson
"Lars T. Kyllingstad" writes: > On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote: > >> I'm exploring D for embedded work as a nice alternative to C/C++ for the >> 32-bitters and am finding it has a nice set of features. But, what is >> the best way handle memory mapped IO? I don't see volati

Re: What's wrong with this code?

2011-01-10 Thread Steven Schveighoffer
On Sat, 08 Jan 2011 15:46:01 -0500, Michal Minich wrote: On Sat, 08 Jan 2011 20:34:39 +, Sean Eskapp wrote: if(left == null) 1) write if (left is null) instead if checking for null. Equality operator is rewritten to a.opEquals(b), which you don't want if you checking f

Re: Templated delegate

2011-01-10 Thread Simen kjaeraas
Mitja wrote: I would like to have a template which returns appropriate delegate, something like this: So like this? module mod1; import std.algorithm; import std.functional; import std.stdio; void main( ) { auto haystack = ["a","b","c"]; auto needle = "b"; auto flt = (string s){retur

Re: Templated delegate

2011-01-10 Thread Stewart Gordon
On 10/01/2011 13:02, Mitja wrote: I would like to have a template which returns appropriate delegate, something like this: For what purpose? All you seem to have is a long-winded identity function. and compiled it like this: dmd mod2.d mod1.d, the program would produce segmentation fault.

Templated delegate

2011-01-10 Thread Mitja
I would like to have a template which returns appropriate delegate, something like this: module mod1; import std.algorithm; import std.array; import std.stdio; template DG(RT, T, F) { auto DG(F fun) { RT delegate(T p)dg; dg = fun; return dg; } } void main() { string[] hayst

Re: Implicit type conversion

2011-01-10 Thread Michal Minich
V Sun, 09 Jan 2011 21:29:32 -0800, Jonathan M Davis wrote: > On Saturday 08 January 2011 13:16:54 Michal Minich wrote: >> Use case: >> >> import std.variant; >> >> void foo (Variant v) {} >> >> void main () { >> Variant v = 3; // ok, this () called v = 3; // ok, >> opAssing

Re: auto declarations

2011-01-10 Thread Jonathan M Davis
On Monday 10 January 2011 01:59:34 Lars T. Kyllingstad wrote: > On Fri, 07 Jan 2011 16:30:24 -0800, Jonathan M Davis wrote: > > On Friday, January 07, 2011 13:32:42 Ellery Newcomer wrote: > >> auto a = 1, b = null; > >> > >> int a = 1, *b = null; > >> > >> > >> [...] > > > > [...] > > > > Howe

Re: auto declarations

2011-01-10 Thread Lars T. Kyllingstad
On Fri, 07 Jan 2011 16:30:24 -0800, Jonathan M Davis wrote: > On Friday, January 07, 2011 13:32:42 Ellery Newcomer wrote: >> auto a = 1, b = null; >> >> int a = 1, *b = null; >> >> >> [...] > > [...] > > However, I'm vere suprised that the first one succeeds. I think that it > should be repor

Re: Memory mapped IO

2011-01-10 Thread Lars T. Kyllingstad
On Sun, 09 Jan 2011 22:44:44 -0800, Dan Olson wrote: > I'm exploring D for embedded work as a nice alternative to C/C++ for the > 32-bitters and am finding it has a nice set of features. But, what is > the best way handle memory mapped IO? I don't see volatile like in C. > Is writing asm {} the