Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Ali Çehreli
On 05/29/2012 07:33 PM, ixid wrote: Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is

Re: ref fields of .tupleof

2012-05-30 Thread Jacob Carlborg
On 2012-05-29 21:18, Sharp wrote: Hi all! I've spend several hours to solve my problem, and I did it! But don't know why it is worked in this way: I'd like to modify all fields of an object by a specific values (for deserialization). If you want a serialization library:

Build / Package system

2012-05-30 Thread Sputnik
There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to manage to get a project to compile in Windows and Linux. Actually the code not have any OS dependence,

Re: Build / Package system

2012-05-30 Thread Dejan Lekic
On Wednesday, 30 May 2012 at 08:13:34 UTC, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to manage to get a project to compile in

Re: Simplified socket creation and handling

2012-05-30 Thread Dejan Lekic
On Friday, 18 May 2012 at 06:35:59 UTC, Jarl André wrote: I am a Java developer who is tired of java.nio and similar complex socket libraries. In Java you got QuickServer, the ultimate protocol creation centered socket library. You don't have to write any channels and readers and what not.

BitArray - preview of what's to come?

2012-05-30 Thread Era Scarecrow
Got some improvements, although the bulk work needs to be tested more otherwise it all seems to work quite well. Once I figure out how to post to GitHub I'll upload a version for everyone to play with and review. Code's not beautiful, but other than the length function, most of it is easy to

Re: BitArray - preview of what's to come?

2012-05-30 Thread Dmitry Olshansky
On 30.05.2012 15:04, Era Scarecrow wrote: [snip] Other features: Slice operations available, so you can slice specific sets of bits. Since opDollar doesn't work right I can't rely on them just yet. uses and accepts ulong for the slices and opIndex. The BitArray footprint is about 36 bytes for

Re: Build / Package system

2012-05-30 Thread Jacob Carlborg
On 2012-05-30 10:13, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to manage to get a project to compile in Windows and Linux. Actually

Re: BitArray - preview of what's to come?

2012-05-30 Thread bearophile
Dmitry Olshansky: Ouch why 36 bytes? That sounds a bit too much. I think 2 - 3 words should be enough. I also suggest the OP to take a look at Bugzilla: http://d.puremagic.com/issues/buglist.cgi?quicksearch=BitArray If you have questions feel free to ask :) Bye, bearophile

problem with template arguments deduction

2012-05-30 Thread Zhenya
Some time ago I decided to write in D something like boost :: bind.But I encountered a problem that the compiler can not deduce the template function. Here are a significant part of the code: template Combination(alias indeces,U...) { // static if(is(typeof(indeces) : uint[])) // {

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
Thank you, that seems to fix it. I'd assumed that const arguments were optimized as ref any way for some reason so hadn't though to try that, hence my confusion about how more and more data was being created.

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
Then again I see how that's a silly though as I'm then expecting const to be immutable. What happens to ref const in a multi-threaded environment? Is it locked by the const ref function until it has finished or can other threads modify it?

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread bearophile
On Wednesday, 30 May 2012 at 13:47:32 UTC, ixid wrote: Thank you, that seems to fix it. I'd assumed that const arguments were optimized as ref any way for some reason so hadn't though to try that, hence my confusion about how more and more data was being created. 1) Time ago I have asked for

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Ali Çehreli
On 05/30/2012 06:49 AM, ixid wrote: What happens to ref const in a multi-threaded environment? Is it locked by the const ref function until it has finished or can other threads modify it? Yes, other threads can modify it but it would have to be marked as 'shared' to begin with. Otherwise

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread sclytrack
On 05/30/2012 04:33 AM, ixid wrote: Having solved Project Euler 300 I wanted to explore which of the strictly superior fold set were redundant but started getting an exception thrown after a few iterations. I've changed the offending part to try to make it as impact-free as possible (my code is

Multidimensional arrays, foreach loops and slices

2012-05-30 Thread Joseph Rushton Wakeling
Hello all, A couple of queries. The first I'm sure has been asked/answered definitively before, but a search doesn't bring anything up: is it possible to foreach() over every element of a multidimensional array, i.e. something like, int[3][4][5] a; foreach(ref int n; a) n

Re: Multidimensional arrays, foreach loops and slices

2012-05-30 Thread bearophile
Joseph Rushton Wakeling: A couple of queries. I think you have to write two small generic functions to do those things (or write inline code). Bye, bearophile

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Dmitry Olshansky
On 30.05.2012 20:40, Joseph Rushton Wakeling wrote: On Wednesday, 30 May 2012 at 06:06:10 UTC, Ali Çehreli wrote: pure int[] solve(const bool[] redundancy, const ushort[LEN - 1][] matrixes, const int[2^^LEN] bits, const int[] numbers) Fixed-length arrays are value types and are copied on the

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread Joseph Rushton Wakeling
On Wednesday, 30 May 2012 at 06:06:10 UTC, Ali Çehreli wrote: pure int[] solve(const bool[] redundancy, const ushort[LEN - 1][] matrixes, const int[2^^LEN] bits, const int[] numbers) Fixed-length arrays are value types and are copied on the stack. Try passing 'bits' as 'const ref' instead of

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
This is specifically a fixed-length array issue? No, fixed and dynamic overflow, though I think one takes one more iteration than the other possibly to cause it.

Re: Exception caused by calling a pure function repeatedly

2012-05-30 Thread ixid
If you mean should multiple threads access it at the same time I think it's safe as the inum used by each thread will never be the same.

std.path.buildPath() and string enumeration

2012-05-30 Thread nrgyzer
Hi, I've the following enumeration: enum path : string { log1 = /var/log1, log2 = /var/log2 } Now... when I try to do the following: string subDirectory = example; string newPath = buildPath(path.log1, subDirectory); I get the following errors: Error: template std.path.buildPath does

Re: std.path.buildPath() and string enumeration

2012-05-30 Thread bearophile
nrgyzer: Is this a bug in std.path.buildPath() or is there anything I'm doing wrong? The signature of buildPath is: immutable(C)[] buildPath(C)(const(C[])[] paths...); But your inputs aren't of the same type. Named enum create their own type. You give buildPath a type string and a type

Re: Build / Package system

2012-05-30 Thread Sputnik
On Wednesday, 30 May 2012 at 13:06:40 UTC, Jacob Carlborg wrote: On 2012-05-30 10:13, Sputnik wrote: There is a build and/or package managment system for D2 that is working? I googled, and I only can find things like dsss or cmaked that don't get updated from a long time ago. I really need to

Re: std.path.buildPath() and string enumeration

2012-05-30 Thread nrgyzer
== Auszug aus bearophile (bearophileh...@lycos.com)'s Artikel nrgyzer: Is this a bug in std.path.buildPath() or is there anything I'm doing wrong? The signature of buildPath is: immutable(C)[] buildPath(C)(const(C[])[] paths...); But your inputs aren't of the same type. Named enum create

Re: Simplified socket creation and handling

2012-05-30 Thread Jarl André
On Wednesday, 30 May 2012 at 08:40:48 UTC, Dejan Lekic wrote: On Friday, 18 May 2012 at 06:35:59 UTC, Jarl André wrote: I am a Java developer who is tired of java.nio and similar complex socket libraries. In Java you got QuickServer, the ultimate protocol creation centered socket library.

Re: Build / Package system

2012-05-30 Thread Jacob Carlborg
On 2012-05-30 20:53, Sputnik wrote: rdmd lloks to work well, escept for two things: 1) I only can compile with dmd. What happend if I like to use gdc to compile ? rdmd --compiler=compiler 2) I need to put the same flags for linking and includes for gtkd that I use in the makefile. I like

Re: Simplified socket creation and handling

2012-05-30 Thread Jarl André
On Wednesday, 30 May 2012 at 08:40:48 UTC, Dejan Lekic wrote: On Friday, 18 May 2012 at 06:35:59 UTC, Jarl André wrote: I am a Java developer who is tired of java.nio and similar complex socket libraries. In Java you got QuickServer, the ultimate protocol creation centered socket library.

Interfacing D to C R standalone math library

2012-05-30 Thread TJB
Hello! I am still wet behind the ears with D. I am trying to interface to an existing C library from the R standalone math library (www.r-project.org). I can call the library quite easily from a C++ program as follows: #include iostream #include time.h #define MATHLIB_STANDALONE #include

Re: BitArray - preview of what's to come?

2012-05-30 Thread Era Scarecrow
On Wednesday, 30 May 2012 at 11:19:43 UTC, Dmitry Olshansky wrote: It all went nice and well... Ouch why 36 bytes? Well for the whole normal size it was 32bytes, or 24 if I drop the ulong 'reserved' which does a minor optimization so it can expand rather than duping every time it expands

Re: std.path.buildPath() and string enumeration

2012-05-30 Thread Artur Skawina
On 05/30/12 20:34, nrgyzer wrote: Hi, I've the following enumeration: enum path : string { log1 = /var/log1, log2 = /var/log2 } Now... when I try to do the following: string subDirectory = example; string newPath = buildPath(path.log1, subDirectory); I get the

Re: BitArray - preview of what's to come?

2012-05-30 Thread Dmitry Olshansky
On 30.05.2012 23:25, Era Scarecrow wrote: On Wednesday, 30 May 2012 at 11:19:43 UTC, Dmitry Olshansky wrote: It all went nice and well... Ouch why 36 bytes? Well for the whole normal size it was 32bytes, or 24 if I drop the ulong 'reserved' which does a minor optimization so it can expand

Re: Simplified socket creation and handling

2012-05-30 Thread Jarl André
On Monday, 21 May 2012 at 19:06:24 UTC, Nathan M. Swan wrote: On Monday, 21 May 2012 at 17:54:56 UTC, Adam D. Ruppe wrote: On Saturday, 19 May 2012 at 20:33:49 UTC, Nathan M. Swan wrote: It has some pitfalls (e.g. I can't find a good way to stop the server) When I use it, I just leave it

Re: Simplified socket creation and handling

2012-05-30 Thread Jarl André
On Wednesday, 30 May 2012 at 20:09:43 UTC, Jarl André wrote: On Monday, 21 May 2012 at 19:06:24 UTC, Nathan M. Swan wrote: On Monday, 21 May 2012 at 17:54:56 UTC, Adam D. Ruppe wrote: On Saturday, 19 May 2012 at 20:33:49 UTC, Nathan M. Swan wrote: It has some pitfalls (e.g. I can't find a good

Re: BitArray - preview of what's to come?

2012-05-30 Thread Era Scarecrow
On Wednesday, 30 May 2012 at 19:43:32 UTC, Dmitry Olshansky wrote: On 30.05.2012 23:25, Era Scarecrow wrote: That overhead is for concatenation ? Did it ever occurred to you that arrays do sometimes reallocate on append. And of course a ~ b should produce new copy (at least semantically).

Re: Multidimensional arrays, foreach loops and slices

2012-05-30 Thread Philippe Sigaud
On Wed, May 30, 2012 at 6:15 PM, Joseph Rushton Wakeling joseph.wakel...@webdrake.net wrote: Hello all, A couple of queries.  The first I'm sure has been asked/answered definitively before, but a search doesn't bring anything up: is it possible to foreach() over every element of a

Re: problem with template arguments deduction

2012-05-30 Thread Philippe Sigaud
I don't see anything wrong per se. It's mainly that the compiler type extraction/deduction is not powerful enough to extract U in your case. You can help it a bit by using std.traits.ParameterTypeTuple: module test; import std.stdio; import std.traits; import std.typetuple; template

Re: Build / Package system

2012-05-30 Thread Zardoz
On Wednesday, 30 May 2012 at 19:12:06 UTC, Jacob Carlborg wrote: On 2012-05-30 20:53, Sputnik wrote: rdmd lloks to work well, escept for two things: 1) I only can compile with dmd. What happend if I like to use gdc to compile ? rdmd --compiler=compiler Wops! 2) I need to put the same

Re: problem with template arguments deduction

2012-05-30 Thread Zhenya
On Wednesday, 30 May 2012 at 22:19:53 UTC, Philippe Sigaud wrote: I don't see anything wrong per se. It's mainly that the compiler type extraction/deduction is not powerful enough to extract U in your case. You can help it a bit by using std.traits.ParameterTypeTuple: module test; import