Re: Problem this names of shared libraries

2012-07-03 Thread Tobias Pankrath
On Wednesday, 4 July 2012 at 05:15:20 UTC, mezozoysky wrote: On Tuesday, 26 June 2012 at 10:23:32 UTC, Jacob Carlborg wrote: On 2012-06-26 10:45, mezozoysky wrote: Hello! I'm not sure if this is the right thread for this question. If you know in which thread this question should be, please poi

Re: Problem this names of shared libraries

2012-07-03 Thread mezozoysky
On Tuesday, 26 June 2012 at 10:23:32 UTC, Jacob Carlborg wrote: On 2012-06-26 10:45, mezozoysky wrote: Hello! I'm not sure if this is the right thread for this question. If you know in which thread this question should be, please point me to it. I've see a strange things using dmd 2.059 with

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread Kenji Hara
On Wednesday, 4 July 2012 at 01:53:40 UTC, Jonathan M Davis wrote: On Wednesday, July 04, 2012 03:48:52 ixid wrote: > 0.writeln(); > > This works. It doesn't with 2.058, are we using different versions? Thanks for adding it to the bug list, I am not knowledgeable enough about D to judge if so

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread ixid
I think I'm using 2.059 actually.

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread Jonathan M Davis
On Wednesday, July 04, 2012 03:48:52 ixid wrote: > > 0.writeln(); > > > > This works. > > It doesn't with 2.058, are we using different versions? Thanks > for adding it to the bug list, I am not knowledgeable enough > about D to judge if something is a bug or if I've just not > understood it. 2.

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread ixid
0.writeln(); This works. It doesn't with 2.058, are we using different versions? Thanks for adding it to the bug list, I am not knowledgeable enough about D to judge if something is a bug or if I've just not understood it.

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread Jonathan M Davis
On Tuesday, July 03, 2012 17:34:21 Jonathan M Davis wrote: > On Wednesday, July 04, 2012 02:20:26 ixid wrote: > > 0.writeln(); > > This works. > > > 01.writeln(); > > This doesn't. > > > etc... > > > > Throw up a series of errors while any other number as the leading > > digit seems to work fi

Re: Literals starting with 0 will not work with UFCS

2012-07-03 Thread Jonathan M Davis
On Wednesday, July 04, 2012 02:20:26 ixid wrote: > 0.writeln(); This works. > 01.writeln(); This doesn't. > etc... > > Throw up a series of errors while any other number as the leading > digit seems to work fine. Why is this? It's probably an artifact of getting rid of octal literals and is c

Literals starting with 0 will not work with UFCS

2012-07-03 Thread ixid
0.writeln(); 01.writeln(); etc... Throw up a series of errors while any other number as the leading digit seems to work fine. Why is this?

Re: bad unary function

2012-07-03 Thread maarten van damme
Ok, everything works great now. thank you maarten

Re: bad unary function

2012-07-03 Thread bearophile
maarten van damme: Now I get a variable with the Result type and this isn't castable or convertable to an array of strings, Right, sorry. (If I don't run the code I show, then it's usually broken in some way). how can I extract the actual result now? Often you don't need an array, a laz

Re: bad unary function

2012-07-03 Thread maarten van damme
Ok, that made sense :) Now I get a variable with the Result type and this isn't castable or convertable to an array of strings, how can I extract the actual result now?

Re: bad unary function

2012-07-03 Thread bearophile
maarten van damme: string [] added=map!("toName(a,parsedschema)")(mod.added); Try with a lambda: string[] added = mod.added.map!(x => toName(x, parsedschema))(); Bye, bearophile

Re: bad unary function

2012-07-03 Thread Philippe Sigaud
On Tue, Jul 3, 2012 at 8:58 PM, maarten van damme wrote: > I have an array of structs and I've written a function that takes as > argument a struct (and an array but this is besides the point) and > returns a unique string. It's not beside the point, I think it's the exact cause of your problem

Re: Redirect stdout and stderr.

2012-07-03 Thread Tobias Pankrath
On Tuesday, 3 July 2012 at 18:39:09 UTC, Artur Skawina wrote: On 07/03/12 20:30, Tobias Pankrath wrote: Is it possible to redirect stdout in a way that all following calls to writeln etc just write to /dev/null or something similar? stdout.open(outfilename, "wt"); artur Thank you. After

Re: Redirect stdout and stderr.

2012-07-03 Thread Wouter Verhelst
"Tobias Pankrath" writes: > Is it possible to redirect stdout in a way that all following calls to > writeln etc just write to /dev/null or something similar? If it's any form of unix, all you need to do is close(1). If you still need the fd afterwards, you want to use dup() first so you can res

bad unary function

2012-07-03 Thread maarten van damme
I have an array of structs and I've written a function that takes as argument a struct (and an array but this is besides the point) and returns a unique string. I wanted to use map to retrieve a string array of all unique strings from that array. I've used it this way: string [] added=map!("toNam

Re: Redirect stdout and stderr.

2012-07-03 Thread Tobias Pankrath
On Tuesday, 3 July 2012 at 18:30:41 UTC, Tobias Pankrath wrote: Is it possible to redirect stdout in a way that all following calls to writeln etc just write to /dev/null or something similar? Thanks! And I need to restore them afterwards.

Re: Redirect stdout and stderr.

2012-07-03 Thread Artur Skawina
On 07/03/12 20:30, Tobias Pankrath wrote: > Is it possible to redirect stdout in a way that all following calls to > writeln etc just write to /dev/null or something similar? stdout.open(outfilename, "wt"); artur

Redirect stdout and stderr.

2012-07-03 Thread Tobias Pankrath
Is it possible to redirect stdout in a way that all following calls to writeln etc just write to /dev/null or something similar? Thanks!

Re: Debug output functions

2012-07-03 Thread Wouter Verhelst
"nazriel" writes: > Try this - http://dpaste.dzfl.pl/3efd9c1b Yes, that's exactly what I need. Thanks. Looks like I was making it far too difficult for myself :-) -- The volume of a pizza of thickness a and radius z can be described by the following formula: pi zz a

Re: Debug output functions

2012-07-03 Thread Wouter Verhelst
Mike Parker writes: > On 7/3/2012 12:12 PM, Wouter Verhelst wrote: >> >> So, I wanted to create a number of functions that would call write(), >> writef(), writefln(), or writeln() with whatever arguments they were >> given, but only if the user had used a 'enable debugging' command-line >> optio

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
On Tuesday, 3 July 2012 at 17:25:18 UTC, bearophile wrote: ixid: In any case with large values of k the branch prediction will be right almost all of the time, explaining why this form is faster than modulo as modulo is fairly slow while this is a correctly predicted branch doing an addition

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
ixid: In any case with large values of k the branch prediction will be right almost all of the time, explaining why this form is faster than modulo as modulo is fairly slow while this is a correctly predicted branch doing an addition if it doesn't make it branchless. That seems the explanat

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
Oops! I have a bad habit of thinking of the power operator as a part of the value rather than as an operator.

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
ixid: I take your point but I think most people know that the equals operators have the lowest associativity. Sorry I meant: nums[iter_next] = total % (10 ^^ 8); Instead of: nums[iter_next] = total % 10^^8; But I presume lot of people know that powers are higher precedence :-) Bye, bearop

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
In any case with large values of k the branch prediction will be right almost all of the time, explaining why this form is faster than modulo as modulo is fairly slow while this is a correctly predicted branch doing an addition if it doesn't make it branchless. The branchless version gives the

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
I tested that, modulus is slower. The compiler is surely converting it to something branchless like: uint iter_next = (iter + 1) * !(iter + 1 > k); I take your point but I think most people know that the equals operators have the lowest associativity.

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
This is becoming a "fixed size circular queue". But maybe a modulus is faster than a branch here. I have tried, and it's slower both in D and C. I don't know why. #include #include #include uint64_t hFib(const uint32_t k, const uint32_t n) { uint64_t *nums = calloc(k + 1, sizeof(uint64

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
ixid: int iter_next = iter + 1 > k? 0 : iter + 1; This is becoming a "fixed size circular queue". But maybe a modulus is faster than a branch here. (It's better when k is always a power of two, you don't need a modulus. And even better if your size is a multiple of the page size

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
Thank you, that was faster. I decided to try the obvious method of reusing the same array giving similar speed to your suggestion while using less memory: ulong f2(int k, int n) { auto nums = new ulong[k + 1]; nums[$ - 1] = 1; int iter = k; ulong total = 0;

Re: popFront causing more memory to be used

2012-07-03 Thread Jonathan M Davis
On Tuesday, July 03, 2012 15:29:51 bearophile wrote: > ixid: > > Given popFront is advancing a range does this mean the > > underlying array is not being deleted? How would one delete the > > information you don't need any more if so? > > I think the GC can't deallocate part of an array. It's a si

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
ixid: It's a pity that the D standard library seems to lack rather a lot of these things. I've taken a better look at your code, for this program a deque wasn't so needed. This is quick: import std.stdio; ulong hFib(in uint k, in uint n) pure nothrow { auto nums = new ulong[k + n + 1];

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
It's a pity that the D standard library seems to lack rather a lot of these things. Permutation functions are also an annoying one not to have. =/

Re: popFront causing more memory to be used

2012-07-03 Thread bearophile
ixid: Given popFront is advancing a range does this mean the underlying array is not being deleted? How would one delete the information you don't need any more if so? I think the GC can't deallocate part of an array. It's a single memory zone, and it has to go all at once. Maybe you need

Re: popFront causing more memory to be used

2012-07-03 Thread ixid
That fixed the memory behaviour and is faster. Not using popFront at all uses the same memory and is faster still. Given popFront is advancing a range does this mean the underlying array is not being deleted? How would one delete the information you don't need any more if so?

Re: Help translating C/C++ snippet to D

2012-07-03 Thread Dustin
On Tuesday, 3 July 2012 at 10:23:06 UTC, Mike Parker wrote: On 7/3/2012 11:34 AM, Dustin wrote: Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (sizeof( array ) /

Re: Debug output functions

2012-07-03 Thread Mike Parker
On 7/3/2012 12:12 PM, Wouter Verhelst wrote: So, I wanted to create a number of functions that would call write(), writef(), writefln(), or writeln() with whatever arguments they were given, but only if the user had used a 'enable debugging' command-line option (or some such). What I first did

Re: Help translating C/C++ snippet to D

2012-07-03 Thread Mike Parker
On 7/3/2012 11:34 AM, Dustin wrote: Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( array[0] ) * (sizeof( array ) != sizeof(void*) || size

Re: Help translating C/C++ snippet to D

2012-07-03 Thread Dustin
On Tuesday, 3 July 2012 at 04:09:22 UTC, nazriel wrote: On Tuesday, 3 July 2012 at 02:34:04 UTC, Dustin wrote: Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (si

Re: Help translating C/C++ snippet to D

2012-07-03 Thread Tongzhou Li
On Tuesday, 3 July 2012 at 02:34:04 UTC, Dustin wrote: Hello, I'm trying to follow along with a C++ tutorial and translate it to D but I don't know C/C++ well enough to understand this #Define statement: #define ARRAY_COUNT( array ) (sizeof( array ) / (sizeof( array[0] ) * (sizeof( array ) !