Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread FG
On 2013-02-10 02:22, Sparsh Mittal wrote: The current reply answers my question, but I was just curious. Can we have a method which divides the 2d region as follows: 8*12 divided into 4*6 to each of 4 threads. Think again if you need that. Things start getting pretty ugly. :) const uint pa

Re: Creating an array of default-constructed class instances

2013-02-09 Thread Simon
On Sunday, 10 February 2013 at 06:57:42 UTC, Ali Çehreli wrote: On 02/09/2013 10:52 PM, Ali Çehreli wrote: > auto things = iota(10).map!(i => new Thing(i))().array; Actually, without the extra parentheses: auto things = iota(10).map!(i => new Thing(i)).array; Ali It's a shame there is

Re: Creating an array of default-constructed class instances

2013-02-09 Thread Ali Çehreli
On 02/09/2013 10:52 PM, Ali Çehreli wrote: > auto things = iota(10).map!(i => new Thing(i))().array; Actually, without the extra parentheses: auto things = iota(10).map!(i => new Thing(i)).array; Ali

Re: Creating an array of default-constructed class instances

2013-02-09 Thread Ali Çehreli
On 02/09/2013 10:14 PM, Simon wrote: > Hi, I'm new to the D programming language. Overall I'm liking > things very much, but I'm still getting the hang of a few things. > > Here's a basic programming pattern: I have a class called Thing, > and while I'm coding I decide I need N Thing instances. >

Re: Creating an array of default-constructed class instances

2013-02-09 Thread Maxim Fomin
On Sunday, 10 February 2013 at 06:14:37 UTC, Simon wrote: Hi, I'm new to the D programming language. Overall I'm liking things very much, but I'm still getting the hang of a few things. Here's a basic programming pattern: I have a class called Thing, and while I'm coding I decide I need N Thi

Creating an array of default-constructed class instances

2013-02-09 Thread Simon
Hi, I'm new to the D programming language. Overall I'm liking things very much, but I'm still getting the hang of a few things. Here's a basic programming pattern: I have a class called Thing, and while I'm coding I decide I need N Thing instances. In C++ that's a matter of std::vector things(

Re: Error: not a property - ?

2013-02-09 Thread Era Scarecrow
On Sunday, 10 February 2013 at 03:45:37 UTC, Jonathan M Davis wrote: On Sunday, February 10, 2013 04:38:56 Era Scarecrow wrote: Where should I add to the bug tracker so the error message can be improved? Just create a new bug report for it: http://d.puremagic.com/issues - Jonathan M Davis

Re: Error: not a property - ?

2013-02-09 Thread Jonathan M Davis
On Sunday, February 10, 2013 04:38:56 Era Scarecrow wrote: > Where should I add to the bug tracker so the error message can > be improved? Just create a new bug report for it: http://d.puremagic.com/issues - Jonathan M Davis

Re: Error: not a property - ?

2013-02-09 Thread Era Scarecrow
On Sunday, 10 February 2013 at 03:24:37 UTC, Jonathan M Davis wrote: On Sunday, February 10, 2013 04:16:26 Era Scarecrow wrote: This is an unexpected error; Seems it's the result of not down-casting a variable-type. Is this a bug? Or just need a better error message? Version: DMD32 D Compiler

Re: Error: not a property - ?

2013-02-09 Thread Jonathan M Davis
On Sunday, February 10, 2013 04:16:26 Era Scarecrow wrote: > This is an unexpected error; Seems it's the result of not > down-casting a variable-type. Is this a bug? Or just need a > better error message? > > Version: DMD32 D Compiler v2.061 > > >struct S { > void test(uint v) @proper

Error: not a property - ?

2013-02-09 Thread Era Scarecrow
This is an unexpected error; Seems it's the result of not down-casting a variable-type. Is this a bug? Or just need a better error message? Version: DMD32 D Compiler v2.061 struct S { void test(uint v) @property {} void test2(ulong v) @property {} } ulong x; S s; s.test2

Re: Line gaps with text files

2013-02-09 Thread Joel
This works better: import std.stdio; import std.file; void main() { //string s = readText("s.txt"); string s; foreach(line; File("s.txt", "r").byLine()) { s ~= line~"\r\n"; } s = s[0..$-2]; writeln([s]); File("s.t

Re: For DLLs, what does export actually do?

2013-02-09 Thread Ben Davis
On 09/02/2013 20:39, Benjamin Thaut wrote: Am 09.02.2013 21:35, schrieb Ben Davis: Hi, I'm working on a multimedia driver DLL, i.e. one that Windows loads on behalf of any program that uses the Windows multimedia API. I'm using a .def file with an EXPORTS section, and I've also got all the rel

Re: For DLLs, what does export actually do?

2013-02-09 Thread Ben Davis
On 09/02/2013 20:44, Andrej Mitrovic wrote: On 2/9/13, Ben Davis wrote: Hi, I'm working on a multimedia driver DLL, i.e. one that Windows loads on behalf of any program that uses the Windows multimedia API. I'm using a .def file with an EXPORTS section, and I've also got all the relevant func

Re: std.process.system and friends

2013-02-09 Thread bioinfornatics
I'm trying to write a script in D for building D projects. They are dbuilder who do this . you can fork it https://github.com/dbuilder-developers/dbuilder

Line gaps with text files

2013-02-09 Thread Joel
I'm using Windows and get gaps (blank lines) when using readText and std.stdio.write. import std.stdio; import std.file; void main() { string s = readText("s.txt"); writeln('[', s, ']'); File("s.txt", "w").write(s); } notepad.exe opens alright, (if you don't save as Fil

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread Sparsh Mittal
for(int i=1; i< N; i++)<==>foreach(i; iota(1, N)) so you can use: foreach(i; parallel(iota(1, N))) { ... } Thanks a lot. This one divides the x-cross-y region by rows. Suppose dimension is 8*12 and 4 parallel threads are there, so current method is dividing by 2*12 to each of 4 thread

Re: A little of coordination for Rosettacode

2013-02-09 Thread bearophile
SomeDude: ... Partial translation of rcrpg-Python: http://codepad.org/SflrKqbT Partial translation of permutations_rank_of_a_permutation-Python: http://codepad.org/El9SQwOE Plus a better Perl implementation of the uniform() on BigInts: http://codepad.org/LGcMpk2f Partial translation of the u

Re: A little of coordination for Rosettacode

2013-02-09 Thread Jos van Uden
On 9-2-2013 23:14, SomeDude wrote: codepad.org doesn't work at all here. Maybe you should use dpaste (or pastebin for other languages) instead ? It's not working for me either. It's probably a temporary problem. It worked fine before.

Re: search of a workaround

2013-02-09 Thread Namespace
This works so far: auto funcAttr = functionAttributes!(fun); if (FunctionAttribute.pure_ & funcAttr) s ~= " pure"; if (FunctionAttribute.nothrow_ & funcAttr) s ~= " nothrow"; if (FunctionAttribute.ref_ & funcAttr) s ~= " ref"; if (!isMutable!(typeof(fun))) s ~= " const"; But it's curious that Fu

Re: Looking for writing parallel foreach kind of statement for nested for-loops

2013-02-09 Thread FG
On 2013-02-09 23:32, Sparsh Mittal wrote: I saw foreach and parallel commands on http://dlang.org/phobos/std_parallelism.html I have nested for-loops as follows: for(int i=1; i< N; i++) { for(int j=1; j < M; j++) { func(i,j); } } Here func(i,j) is such that there is no dep

Re: search of a workaround

2013-02-09 Thread Namespace
On Saturday, 9 February 2013 at 22:23:07 UTC, Namespace wrote: It seems your template has problems with this: struct A { } class B { public: const int bar(ref A a) { return 42; } mixin(rvalue!(bar)); } remove the 'const' and it works fine. It

Re: search of a workaround

2013-02-09 Thread Namespace
It seems your template has problems with this: struct A { } class B { public: const int bar(ref A a) { return 42; } mixin(rvalue!(bar)); } remove the 'const' and it works fine.

Re: A little of coordination for Rosettacode

2013-02-09 Thread SomeDude
On Tuesday, 5 February 2013 at 20:10:37 UTC, bearophile wrote: Jos van Uden: I'll give it a shot if you like. The RCRPG I'd like to try first. I have already partially written those: Partial translation of rcrpg-Python: http://codepad.org/SflrKqbT Partial translation of permutations_rank_o

Re: eating whitespace

2013-02-09 Thread Peter Sommerfeld
Am 09.02.2013, 22:30 Uhr, schrieb Andrej Mitrovic : "f\too\t\n\rb\nar".removechars("\t\n\r") thanks, works... Peter

Re: eating whitespace

2013-02-09 Thread Andrej Mitrovic
On 2/9/13, Peter Sommerfeld wrote: > I wonder what the best, that means the fastest way is > to remove all whitespace " \t\n\r" from as string. > Whitespace are distributed erratically within the string. > > Peter > Try "f\too\t\n\rb\nar".removechars("\t\n\r")

eating whitespace

2013-02-09 Thread Peter Sommerfeld
I wonder what the best, that means the fastest way is to remove all whitespace " \t\n\r" from as string. Whitespace are distributed erratically within the string. Peter

Re: For DLLs, what does export actually do?

2013-02-09 Thread Andrej Mitrovic
On 2/9/13, Ben Davis wrote: > Hi, > > I'm working on a multimedia driver DLL, i.e. one that Windows loads on > behalf of any program that uses the Windows multimedia API. > > I'm using a .def file with an EXPORTS section, and I've also got all the > relevant functions marked as 'export' in the cod

Re: For DLLs, what does export actually do?

2013-02-09 Thread Benjamin Thaut
Am 09.02.2013 21:35, schrieb Ben Davis: Hi, I'm working on a multimedia driver DLL, i.e. one that Windows loads on behalf of any program that uses the Windows multimedia API. I'm using a .def file with an EXPORTS section, and I've also got all the relevant functions marked as 'export' in the co

For DLLs, what does export actually do?

2013-02-09 Thread Ben Davis
Hi, I'm working on a multimedia driver DLL, i.e. one that Windows loads on behalf of any program that uses the Windows multimedia API. I'm using a .def file with an EXPORTS section, and I've also got all the relevant functions marked as 'export' in the code. What I'm finding is, if I remove

windows 64bit variadic functions

2013-02-09 Thread Benjamin Thaut
I have this small test program, it will crash when compiled on x64 windows, but it works fine on 32bit windows. What am I doing wrong? import core.vararg; import std.stdio; void print(string fmt, ...) { auto arg = va_arg!(const(char)[])(_argptr); writefln(fmt ~ arg); } void main(string[] a

Re: best idiom for insert if not present; else use value in assoc array

2013-02-09 Thread Dan
On Saturday, 9 February 2013 at 00:54:58 UTC, Andrej Mitrovic wrote: Feel free to file an enhancement request. http://d.puremagic.com/issues/show_bug.cgi?id=9491 Hopefully that is clear.

Re: How to read fastly files ( I/O operation)

2013-02-09 Thread bioinfornatics
some idea such as letter counting: rename identifier trimming sequence from quality value to cutoff convert to a binary format more idea later

Re: search of a workaround

2013-02-09 Thread bearophile
(I'll ask to remove one limitation): http://d.puremagic.com/issues/show_bug.cgi?id=9489 typeof(scoped!Foo(1))[10] foos; // Not initialized. foreach (i, ref f; foos) // f = new Foo(i * 10); // f = scoped!Foo(i * 10); f.x = i * 10; What's the right/good way to

Re: search of a workaround

2013-02-09 Thread bearophile
monarch_dodra: I mean structs you can pack together in an array, eg: S[10] s10; //10 structs S You can't do that with classes. Sure, you can put 10 class *references* in an array, but the *instances* themselves need to be individually allocated. This kind of works, with some limitations (I

Re: search of a workaround

2013-02-09 Thread monarch_dodra
On Saturday, 9 February 2013 at 12:10:57 UTC, Namespace wrote: In particular, you can't pack classes in a table, for example. I don't understand. I mean structs you can pack together in an array, eg: S[10] s10; //10 structs S You can't do that with classes. Sure, you can put 10 class *refe

Re: search of a workaround

2013-02-09 Thread Namespace
I'm not sure what "in spite of" is. No offense, but you seem to be the only person having problems with this. Maybe I'm the only one who uses so many structs. That happens when you have strong C++ background. I miss '&'. :D And the workarounds are plenty: My proposal, templatizing for auto ref

Re: search of a workaround

2013-02-09 Thread monarch_dodra
On Saturday, 9 February 2013 at 10:05:21 UTC, Namespace wrote: I that directed at me? I'm not sure how it relates? Yes, that's a question for you. Why would you take in spite of everything still structs rather than classes? I'm not sure what "in spite of" is. No offense, but you seem to be

Re: search of a workaround

2013-02-09 Thread Namespace
I that directed at me? I'm not sure how it relates? Yes, that's a question for you. Why would you take in spite of everything still structs rather than classes?

Re: search of a workaround

2013-02-09 Thread monarch_dodra
On Friday, 8 February 2013 at 23:45:09 UTC, Namespace wrote: Thank you. But it looks ugly, and I dislike the use of such constructs for such simple feature. But cool thing. :D I like the meta stuff of D. :) Other favorites? One of the advantages of using this approach though is that it emul