Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Jonathan M Davis
On 2011-06-04 18:01, Andrej Mitrovic wrote: > Problem not so much solved. > > What if I want to keep a stride range? There's no Stride struct > defined in std.range, stride() is defined as an auto function and > hides the type inside the function itself. > > How I can store such an object in modu

Re: Is this a good way of setting up a timer?

2011-06-04 Thread Jonathan M Davis
On 2011-06-04 11:14, Andrej Mitrovic wrote: > Hey, so is there a reason I'm not allowed to use immutable here: > > immutable finalTime = Clock.currTime + dur!"seconds"(5); > > Error: cannot implicitly convert expression > (currTime(cast(immutable(TimeZone))opCall()).opBinary(dur(5L))) of > type S

Re: .lib problem

2011-06-04 Thread Andrej Mitrovic
My bad, coffimplib is actually free and downloadable from: http://ftp.digitalmars.com/coffimplib.zip It's coff2omf which isn't free, that one converts actual object code (not import libraries) to OMF. Sometimes coffimplib works better than implib so you might want to have that in mind.

Re: Template error and parallel foreach bug?

2011-06-04 Thread Ben Grabham
On 05/06/11 03:55, Ben Grabham wrote: On 04/06/11 20:16, simendsjo wrote: On 04.06.2011 20:04, Timon Gehr wrote: ulong SumMultiple3Or5_parallel(uint below) { ulong sum; foreach(i; parallel(iota(below))) { if(i % 3 == 0 || i % 5 == 0) sum += i; // low level data race here. } return sum; } Loop

Re: Template error and parallel foreach bug?

2011-06-04 Thread Ben Grabham
On 04/06/11 20:16, simendsjo wrote: On 04.06.2011 20:04, Timon Gehr wrote: ulong SumMultiple3Or5_parallel(uint below) { ulong sum; foreach(i; parallel(iota(below))) { if(i % 3 == 0 || i % 5 == 0) sum += i; // low level data race here. } return sum; } Loop iterations in a parallel foreach loop m

Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
Problem not so much solved. What if I want to keep a stride range? There's no Stride struct defined in std.range, stride() is defined as an auto function and hides the type inside the function itself. How I can store such an object in module scope? This won't work: auto var = stride([1, 2, 3], 2

Re: Performance of new operator

2011-06-04 Thread bearophile
tschoo: > I am currently trying to port some of the benchmarks from the Computer > Language Benchmark Project in order to get a comparison of D with Java and > C++. Have you seen this page? http://shootout.alioth.debian.org/debian/benchmark.php?test=all&lang=gdc&lang2=gcc&box=1#ratio > I am now

Re: Template error and parallel foreach bug?

2011-06-04 Thread simendsjo
On 04.06.2011 20:04, Timon Gehr wrote: ulong SumMultiple3Or5_parallel(uint below) { ulong sum; foreach(i; parallel(iota(below))) { if(i % 3 == 0 || i % 5 == 0) sum += i; // low level data race here. } return sum; } Loop iterations in a parallel foreach l

Re: So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
Ok, this works: shared Cycle!(int[]) range; So, problem solved? Sometimes I feel like I should just e-mail myself and then give myself the answer instead of posting here. LOL.

Performance of new operator

2011-06-04 Thread tschoo
Hi all, I am currently trying to port some of the benchmarks from the Computer Language Benchmark Project in order to get a comparison of D with Java and C++. While the results of the first benchmark (n-body) look very promising, I am now stuck with my second try: a simple binary tree. The C++ and

So how exactly does one make a persistent range object?

2011-06-04 Thread Andrej Mitrovic
This is my #1 problem with ranges right now: import std.range; int[3] a = [1, 2, 3]; shared range = cycle(a[]); // nope void main() { foo(); } void foo() { // do something with range } test.d(6): Error: static variable a cannot be read at compile time test.d(6): Error: cannot evaluate

Re: Is this a good way of setting up a timer?

2011-06-04 Thread Andrej Mitrovic
Hey, so is there a reason I'm not allowed to use immutable here: immutable finalTime = Clock.currTime + dur!"seconds"(5); Error: cannot implicitly convert expression (currTime(cast(immutable(TimeZone))opCall()).opBinary(dur(5L))) of type SysTime to immutable(SysTime)

Re: Template error and parallel foreach bug?

2011-06-04 Thread Timon Gehr
I just found Project Euler, and tried to solve the first problem. https://gist.github.com/1007840 simendsjo wrote: > I did four implementations: template, ctfe, parallel foreach and > parallel map. > > The template implementation works on low numbers, but not on 1000 > (haven't checked when it fail

Re: 'this' in base class out contract

2011-06-04 Thread Michael Shulman
On Sat, Jun 4, 2011 at 4:27 AM, bearophile wrote: >> x: 14e2fd0 >> Klass2.this: 14e2fd0 >> Klass1.this: 41d1b0 >> Klass1.stored: 14e2fd0 > > Note how much different are the two values of the object references. They may > even be in two different kinds of memory. Klass1.this may be in the static

Re: DMD Backend: Deciding instructions to use/avoid?

2011-06-04 Thread Bernard Helyer
If you run the program in GDB, can you disassemble when the error is given? That may give you the instruction the kernel is assasinating your process for.

Re: Template error and parallel foreach bug?

2011-06-04 Thread simendsjo
On 04.06.2011 14:02, simendsjo wrote: The template implementation works on low numbers, but not on 1000 (haven't checked when it fails). It gives me the following error: euler1.d(23): Error: template instance euler1.SumMultiple3Or5(499LU,Below,57918LU) recursive expansion Ehem.. Guess it fails

Template error and parallel foreach bug?

2011-06-04 Thread simendsjo
I just found Project Euler, and tried to solve the first problem. https://gist.github.com/1007840 I did four implementations: template, ctfe, parallel foreach and parallel map. The template implementation works on low numbers, but not on 1000 (haven't checked when it fails). It gives me the f

Re: 'this' in base class out contract

2011-06-04 Thread bearophile
> x: 14e2fd0 > Klass2.this: 14e2fd0 > Klass1.this: 41d1b0 > Klass1.stored: 14e2fd0 Note how much different are the two values of the object references. They may even be in two different kinds of memory. Klass1.this may be in the static segment instead of the heap :-) Bye, bearophile

Re: 'this' in base class out contract

2011-06-04 Thread bearophile
Michael Shulman: > Why does the following code fail the assertion? I don't know the answer yet, but I suggest to generally compile your D code with the -w compiler switch. I have modified the code, the __gshared and the assert removal are to simplify the asm: import std.c.stdio: printf; clas

Re: DMD Backend: Deciding instructions to use/avoid?

2011-06-04 Thread Jacob Carlborg
On 2011-06-04 11:36, Nick Sabalausky wrote: I'm working with Jacob to try to resolve an issue where D programs compiled on his Ubuntu box (in 32-bit/32-bit) error out on my Ubuntu box with "Illegal instruction". At first we thought it was because my OS was an older version than his. But he tried

Re: private method in interface

2011-06-04 Thread Jacob Carlborg
On 2011-06-03 23:55, Michael Shulman wrote: On Fri, Jun 3, 2011 at 1:02 PM, Jonathan M Davis wrote: And if you don't know about NVI, having a virtual private function is just plain weird. Well, it makes perfect sense to me, once given that in D, 'private' allows access from anywhere in the sa

DMD Backend: Deciding instructions to use/avoid?

2011-06-04 Thread Nick Sabalausky
I'm working with Jacob to try to resolve an issue where D programs compiled on his Ubuntu box (in 32-bit/32-bit) error out on my Ubuntu box with "Illegal instruction". At first we thought it was because my OS was an older version than his. But he tried compiling on an older OS than mine and it

'this' in base class out contract

2011-06-04 Thread Michael Shulman
Why does the following code fail the assertion? class A { void foo() out { assert(stored is this); } body { } } A stored; class B : A { void foo() { stored = this; } } void main () { B x = new B(); x.foo(); }