Re: Is Override Still Mandatory?

2012-11-13 Thread Rob T
On Wednesday, 14 November 2012 at 02:33:47 UTC, bearophile wrote: Rob T: so I hope the suggestion that was made to improve depreciated with warnings and so forth, is implemented. "Deprecated features as warnings" is in the D front since about 7 hours: https://github.com/D-Programming-Langua

Re: Is Override Still Mandatory?

2012-11-13 Thread Rob T
On Wednesday, 14 November 2012 at 02:33:47 UTC, bearophile wrote: Rob T: so I hope the suggestion that was made to improve depreciated with warnings and so forth, is implemented. "Deprecated features as warnings" is in the D front since about 7 hours: https://github.com/D-Programming-Langua

Re: Is Override Still Mandatory?

2012-11-13 Thread bearophile
Rob T: so I hope the suggestion that was made to improve depreciated with warnings and so forth, is implemented. "Deprecated features as warnings" is in the D front since about 7 hours: https://github.com/D-Programming-Language/dmd/commit/5881617a34adc172b830314c17da21d5c834ffd0 Bye, bearop

Re: Is Override Still Mandatory?

2012-11-13 Thread Rob T
On Monday, 12 November 2012 at 03:29:09 UTC, bearophile wrote: I agree. Generally I think warnings should be active on default and disabled on request with a switch :-) Bye, bearophile Agreed! Fortunately I have not written all that much broken code yet. I recall a lot of discussion about ho

Re: Is Override Still Mandatory?

2012-11-13 Thread Rob T
On Monday, 12 November 2012 at 03:08:35 UTC, Jonathan M Davis wrote: On Monday, November 12, 2012 03:58:17 Vijay Nayar wrote: I was under the impression that the attribute "override" was mandatory when replacing a virtual function in a base class. However, code that leaves this out has no errors

Re: Is there a way to initialize a non-assigned structure declaration (or is it a definition)?

2012-11-13 Thread Vijay Nayar
This is merely a syntactic difference in how structs are handled. In D, structs are more akin to low level types like int and have most of the same symantics. So SnonParameterized cnp(5, 3.303); makes about as much sense as int cnp(3); You have two syntax choices to pick from in the D ver

Extent of tail call optimization in D?

2012-11-13 Thread J. Jenkins
In Dr Alexandrescu's "The D Programming Language", on page 12, it is noted that the D compiler will rewrite tail calls within a procedure as loops. Does the compiler rewrite tail calls between procedures as jumps? For example, in pseudo-D: void foo(K)(K cont, stuff..) { // Do things with

Re: Regarding ranges

2012-11-13 Thread Vijay Nayar
This is very well written. Thanks for the link! - Vijay On Tuesday, 13 November 2012 at 16:29:41 UTC, Namespace wrote: On Tuesday, 13 November 2012 at 16:18:43 UTC, Vijay Nayar wrote: On Tuesday, 13 November 2012 at 04:50:54 UTC, bearophile wrote: Do you know if it's possible to write simila

Re: Inferring function argument types from other argument types

2012-11-13 Thread Ali Çehreli
On 11/12/2012 06:55 AM, Joseph Rushton Wakeling wrote: > I'm just curious > if there is any other way to meaningfully determine the type of one > function argument based on the type of another. Hence the playing with > different template argument formulations. > > It just feels really difficult t

Re: Inferring function argument types from other argument types

2012-11-13 Thread Vijay Nayar
Ok, I get it. My understanding is that you have basically two options. * If you want the function to be called with any implicitly castable type, then you must cast it in the function. * If you only want the function to accept the one type, then use is(T == FooT.T1) and you must cast

Re: ref return function using foreach ref result segfaults. Compiler bug?

2012-11-13 Thread Rob T
On Tuesday, 13 November 2012 at 12:31:26 UTC, Kenji Hara wrote: This issue looks like bug8093. http://d.puremagic.com/issues/show_bug.cgi?id=8093 And the code works correctly in git head (dmd2.061alpha). Therefore, I think that the bug is fixed very recently. Kenji Hara Thanks for the resp

Re: Inferring function argument types from other argument types

2012-11-13 Thread Joseph Rushton Wakeling
On 11/13/2012 05:05 PM, Vijay Nayar wrote: I believe this question was asked before, but here is the solution again. The actual reality of what I'm trying to do is slightly more complex: it's more like struct Foo(_T1, _T2) { alias _T1 T1; alias _T2 T2; // etc.

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-13 Thread Nick Sabalausky
On Tue, 13 Nov 2012 11:19:36 -0500 Nick Sabalausky wrote: > On Tue, 13 Nov 2012 11:56:57 +0100 > Don Clugston wrote: > > > > I recommend deskzilla lite. D is on its list of supported > > open-source projects. It maintains a local copy of the entire > > bugzilla database, so you're not restricted

Re: Regarding ranges

2012-11-13 Thread Namespace
On Tuesday, 13 November 2012 at 16:18:43 UTC, Vijay Nayar wrote: On Tuesday, 13 November 2012 at 04:50:54 UTC, bearophile wrote: Do you know if it's possible to write similar code nicely & efficiently with ranges? Bearophile, do you know of a good reference to learn about ranges in D? Due to

Shared value types can not be destructed

2012-11-13 Thread Benjamin Thaut
Apperently this is by design: http://d.puremagic.com/issues/show_bug.cgi?id=8295 To clarify: It is not possible to define a destructor that will be called on the destruction of a shared struct. In a different thread Walter commeted this bug with: "If you include an object designed to work only

Re: Regarding ranges

2012-11-13 Thread Vijay Nayar
On Tuesday, 13 November 2012 at 04:50:54 UTC, bearophile wrote: Do you know if it's possible to write similar code nicely & efficiently with ranges? Bearophile, do you know of a good reference to learn about ranges in D? Due to the language name, Googling for specific topics in D is a bit di

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-13 Thread Nick Sabalausky
On Tue, 13 Nov 2012 11:56:57 +0100 Don Clugston wrote: > > I recommend deskzilla lite. D is on its list of supported open-source > projects. It maintains a local copy of the entire bugzilla database, > so you're not restricted to the slow and horrible html interface. > Awesome! I wish GitHub ha

Re: Inferring function argument types from other argument types

2012-11-13 Thread Vijay Nayar
I believe this question was asked before, but here is the solution again. struct Foo(_T1, _T2) { alias _T1 T1; alias _T2 T2; T1 a; T2 b; } FooT.T1 func(FooT, T)(FooT foo, T x) if (is(FooT.T1) && is(T : FooT.T1)) { return x * foo.a; } void main() { auto foo = Foo!(size_t, string)(

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-13 Thread Andrej Mitrovic
On 11/13/12, Don Clugston wrote: > I recommend deskzilla lite. D is on its list of supported open-source > projects. It maintains a local copy of the entire bugzilla database, so > you're not restricted to the slow and horrible html interface. Wow, I had no idea they had this. I've added a note a

Re: ref return function using foreach ref result segfaults. Compiler bug?

2012-11-13 Thread Kenji Hara
On Tuesday, 13 November 2012 at 08:50:16 UTC, Rob T wrote: Hard to describe this problem, see code and read comments below. class A { private int _v; this( int a_v ) { _v = a_v; } @property size_t length() { return 1; } int opApply( int delegate( r

Re: Compilable Recursive Data Structure ( was: Recursive data structure using template won't compile)

2012-11-13 Thread Don Clugston
On 13/11/12 06:51, Rob T wrote: On Monday, 12 November 2012 at 14:28:53 UTC, Andrej Mitrovic wrote: On 11/12/12, Andrej Mitrovic wrote: On 11/12/12, Don Clugston wrote: Yeah. Though note that 1000 bug reports are from bearophile. Actually only around 300 remain open: http://d.puremagic.com

ref return function using foreach ref result segfaults. Compiler bug?

2012-11-13 Thread Rob T
Hard to describe this problem, see code and read comments below. class A { private int _v; this( int a_v ) { _v = a_v; } @property size_t length() { return 1; } int opApply( int delegate( ref int a_v ) a_dg ) { int result = 0; for ( u