Re: Can I call the default opAssign after overloading opAssign?

2012-11-18 Thread Jonathan M Davis
On Monday, November 19, 2012 07:21:10 Rob T wrote: > I think you've cleared things up for me. > > When I define an opAssign, I'm not really overriding a default > opAssign, because there is none, instead I'm overriding the > default behavior which is to perform a memcopy-like operation. > > So if

Re: Can I call the default opAssign after overloading opAssign?

2012-11-18 Thread Rob T
I think you've cleared things up for me. When I define an opAssign, I'm not really overriding a default opAssign, because there is none, instead I'm overriding the default behavior which is to perform a memcopy-like operation. So if I defined an opAssign function, but for some odd reason I w

Re: Can I call the default opAssign after overloading opAssign?

2012-11-18 Thread Jonathan M Davis
On Monday, November 19, 2012 06:01:55 Rob T wrote: > I assume that when I define an opAssign, only the opAssign that I > define gets called, which means there's no blit or postblit being > called ever again. > > I may be thoroughly confused at this point. Is there both a blit > and a postblit, and

Re: Can I call the default opAssign after overloading opAssign?

2012-11-18 Thread Rob T
I assume that when I define an opAssign, only the opAssign that I define gets called, which means there's no blit or postblit being called ever again. I may be thoroughly confused at this point. Is there both a blit and a postblit, and an optional opAssign that when specified will override bo

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread bearophile
Tyro[17]: Why not simply allow new double[N][3][M]; ? Seems a lot more intuitive/succinct than a separate []() implementation. I think with that there is some ambiguity regarding what coordinates are fixed-sized arrays and what dynamic arrays. Bye, bearophile

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread Jonathan M Davis
On Sunday, November 18, 2012 21:06:58 Tyro[17] wrote: > On 11/18/12 8:14 PM, bearophile wrote: > >> Why is no one complaining about this array allocation syntax? > > > > A syntax I like is: > > > > new double[][3][](N, M) > > Why not simply allow new double[N][3][M]; ? > Seems a lot more intuiti

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread Tyro[17]
On 11/18/12 8:14 PM, bearophile wrote: Why is no one complaining about this array allocation syntax? A syntax I like is: new double[][3][](N, M) Why not simply allow new double[N][3][M]; ? Seems a lot more intuitive/succinct than a separate []() implementation. Where: - The numbers inside

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread Tyro[17]
On 11/18/12 7:53 PM, bearophile wrote: Tyro[17]: What is the proper way to declare a multidimensional array? In Java, I can do: double[][] a = new double[M][N]; In D (hopefully I have not swapped the to sizes, it's a too much common mistake in my D code): auto a = new double[][](M, N);

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread bearophile
Why is no one complaining about this array allocation syntax? A syntax I like is: new double[][3][](N, M) Where: - The numbers inside the [] must be always compile-time constants, and they always refer to fixed-sized arrays. - The numbers inside the () are run-time values and must be used fo

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread bearophile
auto b = new double[][3][](M, N); That doesn't compile, I don't know why. The D array syntax allocation syntax is a bit of a mess. So to do that you have to write: auto b = new double[][3][](N); Or: auto b = new double[][3][N]; And then fill the arrays with a loop. Why is no one complaining

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread bearophile
auto a = new double[][](M, N); That's a way to declare and initialize a dynamic array of dynamic arrays. If you want to allocate something else, you need a different syntax. Example, this creates something rather different: auto b = new double[][3][](M, N); In D there are both dynamic arra

Re: declaration/initialization of multidimensional arrays

2012-11-18 Thread bearophile
Tyro[17]: What is the proper way to declare a multidimensional array? In Java, I can do: double[][] a = new double[M][N]; In D (hopefully I have not swapped the to sizes, it's a too much common mistake in my D code): auto a = new double[][](M, N); Bye, bearophile

declaration/initialization of multidimensional arrays

2012-11-18 Thread Tyro[17]
What is the proper way to declare a multidimensional array? In Java, I can do: double[][] a = new double[M][N]; D does not allow this because of two reasons. 1) M & N are variables and cannot be read at compile time even if they are explicitly initialized. Error: variable N c

Re: Strange template alias behaviour

2012-11-18 Thread Simen Kjaeraas
On 2012-05-18 17:11, Maxim Fomin wrote: Changing template parameter to Bar.f or bar.f affects value of bar.f.data. Seems to be a bug. It's a bug. Further reduction: import std.stdio; mixin template Foo() { string data = "default"; } struct Bar { mixin Foo f; } string get_data(alias u

Re: Stack allocated arrays

2012-11-18 Thread Namespace
On Sunday, 18 November 2012 at 16:01:10 UTC, Tobias Pankrath wrote: On 18.11.2012 16:46, Namespace wrote: Ok, understood. I hoped that I could create a better interface. I think a good interface would be a generic array class/struct that can be parameterized to use a stack allocator. The be

Re: Strange template alias behaviour

2012-11-18 Thread Maxim Fomin
Reduced: import std.stdio; mixin template Foo() { string data = "default"; } class Bar { string data; mixin Foo f; } void check_data(alias M, T)(T obj) { writeln(M.stringof); writeln(obj.data); writeln(obj.f.data); } void main() { Bar bar = new Bar; bar.data = "Bar"; bar.f.d

Re: Stack allocated arrays

2012-11-18 Thread Tobias Pankrath
On 18.11.2012 16:46, Namespace wrote: Ok, understood. I hoped that I could create a better interface. I think a good interface would be a generic array class/struct that can be parameterized to use a stack allocator.

Re: Stack allocated arrays

2012-11-18 Thread Namespace
Ok, understood. I hoped that I could create a better interface.

Re: Stack allocated arrays

2012-11-18 Thread Tobias Pankrath
On 18.11.2012 16:21, bearophile wrote: Tobias Pankrath: Maybe the array is allocated in the frame of the constructor which is lost afterwards. That's probably right, you can't use alloca that way (It seems my answer yesterday got lost). Bye, bearophile I just took a look. It's in my mailbo

Re: Stack allocated arrays

2012-11-18 Thread bearophile
Tobias Pankrath: Maybe the array is allocated in the frame of the constructor which is lost afterwards. That's probably right, you can't use alloca that way (It seems my answer yesterday got lost). Bye, bearophile

Re: Stack allocated arrays

2012-11-18 Thread Tobias Pankrath
On Sunday, 18 November 2012 at 01:55:48 UTC, Namespace wrote: Code: http://dpaste.dzfl.pl/6ae9f91a Can someone explain me these results (switch the version statement from 'none' to 'all' in 'reserve')? Is it possible that I blown the stack frame? If so: why and can my code/idea work? Maybe th

Re: struct + writeln

2012-11-18 Thread Artur Skawina
On 11/18/12 14:15, Namespace wrote: > Why are there so many copies of my struct if I give it to writeln? > http://dpaste.dzfl.pl/414e7d93 > This problem occurs even if I have a 'toString' method. phobos/writeln design issue. It just always blindly copies the things it needs to print/format. Unnece

Re: struct + writeln

2012-11-18 Thread bearophile
Namespace: Why are there so many copies of my struct if I give it to writeln? http://dpaste.dzfl.pl/414e7d93 This problem occurs even if I have a 'toString' method. It looks the compiler is working correctly here. It seems a pure Phobos/writeln problem. Bye, bearophile

Re: template error instantiating

2012-11-18 Thread Timon Gehr
On 11/18/2012 09:19 AM, Maxim Fomin wrote: On Saturday, 17 November 2012 at 23:28:21 UTC, Timon Gehr wrote: On 11/18/2012 12:14 AM, Manfred Nowak wrote: Maxim Fomin wrote: related to the issue? ... I can see that the definition is ambiguous. And if the coder didnt't realize the ambiguousnes

Re: template error instantiating

2012-11-18 Thread David Nadlinger
On Sunday, 18 November 2012 at 10:19:47 UTC, Manfred Nowak wrote: I will be quiet on this, because non formal specifications tend to have ambiguities and I believe that the ambiguity I see escapes the intended scope; but I am not willing to check for this---and it is fruitless to explain such cas

Re: DWT vs GtkD

2012-11-18 Thread Jacob Carlborg
On 2012-11-17 18:55, JN wrote: DWT vs GtkD Wiki (http://prowiki.org/wiki4d/wiki.cgi?GuiLibraries) claims they are both "mature and ready to be used". How true is that? As for my requirements - I'd like my app to run under Windows and Linux, also it would be great if it was compilable under GDC.

Re: template error instantiating

2012-11-18 Thread Manfred Nowak
Maxim Fomin wrote: > How this is related I will be quiet on this, because non formal specifications tend to have ambiguities and I believe that the ambiguity I see escapes the intended scope; but I am not willing to check for this---and it is fruitless to explain such cases. -manfred

Re: template error instantiating

2012-11-18 Thread Maxim Fomin
On Saturday, 17 November 2012 at 23:28:21 UTC, Timon Gehr wrote: On 11/18/2012 12:14 AM, Manfred Nowak wrote: Maxim Fomin wrote: related to the issue? ... I can see that the definition is ambiguous. And if the coder didnt't realize the ambiguousness as you do ... -manfred The code give

Re: template error instantiating

2012-11-18 Thread Maxim Fomin
On Saturday, 17 November 2012 at 23:14:56 UTC, Manfred Nowak wrote: Maxim Fomin wrote: related to the issue? ... I can see that the definition is ambiguous. And if the coder didnt't realize the ambiguousness as you do ... -manfred There is compilation error when instantiating class templat