Re: std.concurrency, speed, etc.

2011-02-04 Thread Jonathan M Davis
On Friday 04 February 2011 16:09:08 Sean Kelly wrote: > Adam Conner-Sax Wrote: > > 1) I couldn't get the synchronized class version (as opposed to using > > synchronized statements in the functions) to run. It would hang in odd > > ways. > > > > This may be related to a bug I reported earlier (a

Re: std.concurrency, speed, etc.

2011-02-04 Thread Adam Conner-Sax
== Quote from Sean Kelly (s...@invisibleduck.org)'s article > Adam Conner-Sax Wrote: > > > > 1) I couldn't get the synchronized class version (as opposed to using > > synchronized statements in the functions) to run. It would hang in odd > > ways. > > This may be related to a bug I reported earl

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Sean Kelly
Peter Alexander Wrote: > > Things might be easier if the error messages associated with D's > concurrent features weren't especially unhelpful (for example, trying to > spawn a thread with reference type parameters just gives you a 'no match > for spawn template' error). It's nice that it stops

Re: std.concurrency, speed, etc.

2011-02-04 Thread Sean Kelly
Adam Conner-Sax Wrote: > > 1) I couldn't get the synchronized class version (as opposed to using > synchronized statements in the functions) to run. It would hang in odd ways. > This may be related to a bug I reported earlier (and Sean was helpful enough > to fix!) so this may be moot. 'synchro

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Sean Kelly
Peter Alexander Wrote: > > How would you do it with message passing though? As I understand, all of > the std.concurrency message passing routines are blocking, and I need > this to be asynchronous. What do you mean by blocking? The receive call will block until a message matching one of the

Re: Asynchronous concurrency with reference types

2011-02-04 Thread spir
On 02/05/2011 12:21 AM, Peter Alexander wrote: Things might be easier if the error messages associated with D's concurrent features weren't especially unhelpful (for example, trying to spawn a thread with reference type parameters just gives you a 'no match for spawn template' error). It's nice t

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Peter Alexander
On 4/02/11 8:42 PM, spir wrote: On 02/04/2011 07:18 PM, Peter Alexander wrote: I would like to be able to spawn a thread, which does a lot of work, and then returns (in some way) the result of its computations to the main thread. I would really like to avoid copying its results if possible. Log

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Jesse Phillips
spir Wrote: > (I have few exp in the paradigm, so don't believe me.) > > It seems your problem is a typical case that cannot be safe as is. > Essentially, > IIUC, you want a shared set of data to be fed (more generally: mutated) from > a > thread, while another thread (here, the main one) pro

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Peter Alexander
On 4/02/11 8:23 PM, Jesse Phillips wrote: Peter Alexander Wrote: Essentially, the work that doWork does needs to be returned to the main thread asynchronously, and obviously in a thread-safe manner. What's the best way to do this? The above won't work because ~= isn't atomic, so you can't do i

Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
On 02/04/2011 02:31 PM, Jesse Phillips wrote: Ellery Newcomer Wrote: I think this was the impetus for foreach_reverse, or at least it is one place where it is pretty handy. Don't remember what all there is in D1, but in D2 you could do something like foreach_reverse(i; 0u .. 10u){ // iterates

Re: unsigned int in for loops

2011-02-04 Thread Jonathan M Davis
On Friday 04 February 2011 12:31:06 Jesse Phillips wrote: > Ellery Newcomer Wrote: > > I think this was the impetus for foreach_reverse, or at least it is one > > place where it is pretty handy. Don't remember what all there is in D1, > > but in D2 you could do something like > > > > foreach_rever

Re: Asynchronous concurrency with reference types

2011-02-04 Thread spir
On 02/04/2011 07:18 PM, Peter Alexander wrote: I would like to be able to spawn a thread, which does a lot of work, and then returns (in some way) the result of its computations to the main thread. I would really like to avoid copying its results if possible. Logically, what I would like is some

Re: unsigned int in for loops

2011-02-04 Thread Jesse Phillips
Ellery Newcomer Wrote: > I think this was the impetus for foreach_reverse, or at least it is one > place where it is pretty handy. Don't remember what all there is in D1, > but in D2 you could do something like > > foreach_reverse(i; 0u .. 10u){ > // iterates over 9,8,7 .. 1,0 > } There was so

Re: Asynchronous concurrency with reference types

2011-02-04 Thread Jesse Phillips
Peter Alexander Wrote: > Essentially, the work that doWork does needs to be returned to the main > thread asynchronously, and obviously in a thread-safe manner. > > What's the best way to do this? The above won't work because ~= isn't > atomic, so you can't do it on shared data. Disclaimer: I

Re: unsigned int in for loops

2011-02-04 Thread Ellery Newcomer
I think this was the impetus for foreach_reverse, or at least it is one place where it is pretty handy. Don't remember what all there is in D1, but in D2 you could do something like foreach_reverse(i; 0u .. 10u){ // iterates over 9,8,7 .. 1,0 } for more complex iterations, I suppose you're stu

Re: unsigned int in for loops

2011-02-04 Thread spir
On 02/04/2011 05:14 PM, eles wrote: recently i was hit by an old-known programming error, using unsigned int in for loops could get into infinite traps: http://stackoverflow.com/questions/665745/whats-the-best-way-to-do-a-reverse- for-loop-with-an-unsigned-index Aha! was trapped as well recent

Re: std.concurrency, speed, etc.

2011-02-04 Thread bearophile
Adam Conner-Sax: > I wrote the tester as an exercise in learning D. The language is great; > perfect for me as someone who loved generics in C++ but found that all the > cool things you could do got ugly and messy fast. Few notes on the form of your code: - I suggest to use module names all in l

Re: Can't evaluate enum at compile time

2011-02-04 Thread Andrej Mitrovic
On 2/4/11, bearophile wrote: > Most of Phobos is written in D, and D distributions contain full source > code, so in similar cases you just need to take a look at the sources of > Phobos and do some experiments to locate the problem. Yeah. I was in the middle of something so I was too lazy to go

Re: Can't evaluate enum at compile time

2011-02-04 Thread bearophile
> I will file it in bugzilla: http://d.puremagic.com/issues/show_bug.cgi?id=5524

Re: Can't evaluate enum at compile time

2011-02-04 Thread bearophile
Andrej Mitrovic: > std.path is supposed to work on strings, it doesn't touch std.file at all. > Why can't it run at compile time? Most of Phobos is written in D, and D distributions contain full source code, so in similar cases you just need to take a look at the sources of Phobos and do some

Asynchronous concurrency with reference types

2011-02-04 Thread Peter Alexander
I would like to be able to spawn a thread, which does a lot of work, and then returns (in some way) the result of its computations to the main thread. I would really like to avoid copying its results if possible. Logically, what I would like is something like this: class LotsOfData { ... } v

Re: unsigned int in for loops

2011-02-04 Thread bearophile
eles: > so, i D (1 or 2) is counter-attacking in some way (for example, disabling > implicit casting of (-1) to UINT_MAX). I don't understand your question very well, but at the moment D is doing nearly nothing to avoid this kind of bugs (I have written probably tens of posts on this topic, wit

Re: ASM access to array

2011-02-04 Thread bearophile
Heinz: > This results in a much robust code. That's the right way to do it, with a D fallback. > You are right too about the "load-load-load processing-processing-processing > store-store-store instead a load-processing-store load-processing-store > load-processing-store" thing. I'll modify m

Re: ASM access to array

2011-02-04 Thread Heinz
bearophile, Thank you so much for all your help. It seems you're very into ASM. I kept the D_InlineAsm_X86 in my code as you suggested. The code i gave here was just an example. But my code's version implementation looks like this: version(D_InlineAsm_X86) { // ASM Code. } else { // D cod

Can't evaluate enum at compile time

2011-02-04 Thread Andrej Mitrovic
import std.path : join; enum rootdir = r"C:\Path\"; enum testdir = join(rootdir, "simple"); void main() { } enumBug.d(4): Error: variable __arrayArg774 is used before initialization enumBug.d(4): Error: cannot evaluate join("C:\\Path\\","simple",(const(char)[][0u] __arrayArg774 = void; , cast

unsigned int in for loops

2011-02-04 Thread eles
hi everybody, recently i was hit by an old-known programming error, using unsigned int in for loops could get into infinite traps: http://stackoverflow.com/questions/665745/whats-the-best-way-to-do-a-reverse- for-loop-with-an-unsigned-index so, i D (1 or 2) is counter-attacking in some way (for

std.concurrency, speed, etc. (part 2)

2011-02-04 Thread Adam Conner-Sax
attaching more files... begin 644 PrettyPrint.d M:6UP;W)T('-T9"YF;W)M870[#0II;7!O7!E8V]N&-E<'1I;VX[#0II;7!OTPL0RQ2?0T*#0H-"G-TPT*("!A=71O(&$@/2!A<'!E;F1E2!J=7-T:69Y+"`-"@D)"2`@("!I;B!S M=')I;F=;72!F;W)M871S+"!I;B!4(&%R9W,I#0I[#0H@(&5N9F]R8V4H8V]L M=6UN7W=I9'1H3L-"B`@5M=(&IUPT* M("`@(&$N<'5T*&9O5MK7

exercise on range: lexeme stream

2011-02-04 Thread spir
[sorry for double posting, first sent this to D's general list by error] Hello, I have a working lexing toolkit that allows defining a lexer from a language's "morphology", then let it scan sources. The result is a 'LexemeStream' struct, which just wraps an array of Lexeme's; for simplicity, e

Re: std.regex bug? My regex doesn't match what it's supposed to.

2011-02-04 Thread Alex Folland
On 2011-02-03 17:03, Jesse Phillips wrote: Alex Folland Wrote: The problematic string: Guaton_at_9min59sec.WAgame Might I suggest using a simpler regex? It gives the ability to do better error checking/reporting. Instead of adding all the misspellings for minute and second, just capture t

Re: ASM access to array

2011-02-04 Thread bearophile
Heinz: > void myFunct() > { > uint* p = myarray.ptr; > asm > { > mov EBX, p; > > mov EAX, [EBX + 4]; > rol EAX, 8; > mov [EBX + 4], EAX; > > mov EAX, [EBX + 8]; > rol EAX, 16; > mov [EBX + 8], EAX; > > mov EAX, [EBX + 1