Coexistence of static and unstatic method

2012-06-30 Thread Namespace
I have this class: http://dpaste.dzfl.pl/95990b4e and would like that this call Vector2s vec = Vector2s(42, 23); returns a new object and that this call vec(44, 26) set the x and y coords from the existing object to 44 and 26. Is that possible? I try to check if the object is initialize with

Re: Range to array

2012-06-30 Thread Namespace
std.range already publicly import std.array. Oh, good to known. Not to mention, if you're using ranges heavily, it's not all that uncommon to not actually need std.array.array very often. In general, if you're constantly converting ranges to arrays, then I'd argue that you're doing

Re: Range to array

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 11:06:06 Namespace wrote: But a Range don't match any function that accept arrays. Or should i prefer to use Ranges instead of arrays? In general, functions should take ranges, not arrays. They're far more flexible that way. Requiring an array is generally overly

Re: Coexistence of static and unstatic method

2012-06-30 Thread Namespace
I've tried different things and that here indeed compiles, but does not work as it should/I want. typeof(this) opCall(U, V)(U x, V y) if (__traits(compiles, { this.x = 5; })) { writeln(unstatic opCall); this.Set(x, y); return this; } static Vector2D!(T) opCall(U,

Re: Coexistence of static and unstatic method

2012-06-30 Thread Jacob Carlborg
On 2012-06-30 10:56, Namespace wrote: I have this class: http://dpaste.dzfl.pl/95990b4e and would like that this call Vector2s vec = Vector2s(42, 23); returns a new object and that this call vec(44, 26) set the x and y coords from the existing object to 44 and 26. Is that possible? I try to

Re: Range to array

2012-06-30 Thread bearophile
Namespace: Or should i prefer to use Ranges instead of arrays? There is no short answer to this question. Arrays and lazy ranges have different qualities, so they are better for different situations. Arrays use more memory, but in some situations they are faster. Lazy ranges can be a

Fixed size multidimensional array at runtime

2012-06-30 Thread Vidar Wahlberg
I know multidimensional arrays has been brought up many times, although I was not able to find a clear answer to my question. My knowledge of what's going on behind the curtains is somewhat lacking, please correct me if my assumptions are incorrect. Creating a dynamic multidimensional array

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 20:21:57 Vidar Wahlberg wrote: I know multidimensional arrays has been brought up many times, although I was not able to find a clear answer to my question. My knowledge of what's going on behind the curtains is somewhat lacking, please correct me if my assumptions

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Vidar Wahlberg
On Saturday, 30 June 2012 at 18:32:09 UTC, Jonathan M Davis wrote: In D, static arrays are always fixed in size, and that size must be known at compile time, whereas dynamic arrays are never fixed in size (unless they're immutable), and the size doesn't need to be known at compile time. There

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 21:01:02 Vidar Wahlberg wrote: On Saturday, 30 June 2012 at 18:32:09 UTC, Jonathan M Davis wrote: In D, static arrays are always fixed in size, and that size must be known at compile time, whereas dynamic arrays are never fixed in size (unless they're

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Vidar Wahlberg
On Saturday, 30 June 2012 at 19:06:31 UTC, Jonathan M Davis wrote: On Saturday, June 30, 2012 21:01:02 Vidar Wahlberg wrote: This is a very good suggestion, I hadn't thought of this possibility, this way I can get my beloved matrix[x][y]; instead of something like matrix.get(x, y);. It might

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 21:27:15 Vidar Wahlberg wrote: On Saturday, 30 June 2012 at 19:06:31 UTC, Jonathan M Davis wrote: On Saturday, June 30, 2012 21:01:02 Vidar Wahlberg wrote: This is a very good suggestion, I hadn't thought of this possibility, this way I can get my beloved

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Denis Shelomovskij
30.06.2012 22:21, Vidar Wahlberg пишет: I know multidimensional arrays has been brought up many times, although I was not able to find a clear answer to my question. My knowledge of what's going on behind the curtains is somewhat lacking, please correct me if my assumptions are incorrect.

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Vidar Wahlberg
On Saturday, 30 June 2012 at 19:35:33 UTC, Denis Shelomovskij wrote: You could be interested in my answer on this thread: http://forum.dlang.org/thread/mailman.1578.1339962782.24740.digitalmars-d-le...@puremagic.com Thanks for the tip, that is interesting (I'm surprised I didn't come across

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Roman D. Boiko
On Saturday, 30 June 2012 at 20:06:58 UTC, Vidar Wahlberg wrote: On Saturday, 30 June 2012 at 19:35:33 UTC, Denis Shelomovskij wrote: You could be interested in my answer on this thread: http://forum.dlang.org/thread/mailman.1578.1339962782.24740.digitalmars-d-le...@puremagic.com Thanks for

CURL: Save response to string

2012-06-30 Thread Nrgyzer
Hi guys, I know... there's a lib for curl but I'm using an old CURL-binding for D... I've the following problem: I'm sending my login data to a web page and I want store the response of curl_easy_perform() in a string. So I'm using the following few lines to do that: string temp; size_t

Re: CURL: Save response to string

2012-06-30 Thread Jonathan M Davis
On Saturday, June 30, 2012 21:49:51 Nrgyzer wrote: Hi guys, I know... there's a lib for curl but I'm using an old CURL-binding for D... I've the following problem: I'm sending my login data to a web page and I want store the response of curl_easy_perform() in a string. So I'm using the

Re: CURL: Save response to string

2012-06-30 Thread simendsjo
On Sat, 30 Jun 2012 23:49:51 +0200, Nrgyzer nrgy...@gmail.com wrote: Hi guys, I know... there's a lib for curl but I'm using an old CURL-binding for D... I've the following problem: I'm sending my login data to a web page and I want store the response of curl_easy_perform() in a string. So

function pointer when a function is overloaded.

2012-06-30 Thread deadalnix
Simple question. How to I get a function pointer to one of the foo functions in this case : void foo(int i); void foo(long i);

Regarding topN and topNCopy

2012-06-30 Thread bearophile
Three related questions, about three possible Phobos little enhancement requests. This curious code compiles and sorts in reverse the arrays a and b according to the a,b pairs: import std.stdio, std.algorithm, std.range; void main() { auto a = [10, 20, 30]; auto b = [c, b, a];

Re: function pointer when a function is overloaded.

2012-06-30 Thread dnewbie
import std.stdio; alias void function(int) fooInt; alias void function(long) fooLong; int main(string[] args) { fooInt f1 = foo; fooLong f2 = foo; f1(1L); f2(1L); return 0; } void foo(int i) { writeln(foo(int i)); } void foo(long i) { writeln(foo(long i)); }