Re: Struct copy and destruction

2011-04-10 Thread Morlan
I was curious too, so found in Section 7.1.5.1 the description of opAssign using a swap. That explains it I think. Section 7.1.5.1 does not apply because it concerns the case where you define your own overload of the assignment operator. In my example the default assignment is used. The

Re: Struct copy and destruction

2011-04-09 Thread Morlan
The essence of my problem is why is the destructor called as a result of the assignment in the first place? There is no information about this behaviour in the language reference. Can anyone explain this?

Re: Struct copy and destruction

2011-04-09 Thread Morlan
It sounds reasonable. But I cannot find information about this behaviour in the Language Reference or TDPL book. Can you point to a relevant source?

string and char[]

2011-04-08 Thread Morlan
It is OK if I write int[char[]] asr; asr[hello] = 10; but the following does not compile: char[] car = hello; What is the explanation for this behaviour?

Re: string and char[]

2011-04-08 Thread Morlan
int[char[]] is consistently used D's Language reference to illustrate associative arrays. For me it looks like something that should not compile. Of course int[string] works without problem so I wonder why int[char[]] was used as an example. Was it carried over from D1 reference perhaps?

Re: string and char[]

2011-04-08 Thread Morlan
Of course, by saying it should not compile I mean things like asr[hello] should not compile.

Language Reference

2011-04-05 Thread Morlan
After clicking on Template in the left menu of Language Reference on http://d-programming-language.org/ page, the menu collapses to start menu, while for other items it remains visible.

Language Reference: Usual Arithmetic Conversions

2011-04-05 Thread Morlan
The following section from the Language Reference does not correspond to the current dmd compiler (v2.052, Windows) behaviour: Integer values cannot be implicitly converted to another type that cannot represent the integer bit pattern after integral promotion. For example: ubyte u1 =

foreach overloading

2011-04-04 Thread Morlan
The section 12.9 (page 380) in the TDPL books presents foreach overloading. However the example shown is problematic because there is no method of automatic initializing of the _root variable without which foreach overloading cannot work properly (obviously the loop steering variable has to be

Why does it not compile?

2011-03-24 Thread Morlan
import std.stdio; void Foo(T:T*)(T arg) if(!is(T==int)) { writeln(arg of Foo:, arg, typeid(T)); } void Foo(T:T*)(T arg) if(is(T==int)) { writeln(int Foo!); } void main() { Foo!(long*)(54); }

Re: Why does it not compile?

2011-03-24 Thread Morlan
I did not ask what to do to compile it. I knew that 54L would do. The problem is that in the example I explicitely specify the template parameter as long* so there is no reason for the compiler to try and guess T from the type of the function argument. There is something wrong here.

Re: Why does it not compile?

2011-03-24 Thread Morlan
The program below compiles. Clearly the if constraints in my original example are causing trouble. It seems like a bug to me. import std.stdio; void Foo(T:T*)(T arg) { writeln(arg of Foo:, arg, typeid(T)); } void main() { Foo!(long*)(54); }

is expression: library reference

2011-03-24 Thread Morlan
The library refernce has the following text concerning the is expression: 5. is ( Type Identifier : TypeSpecialization ) The condition is satisfied if Type is the same as TypeSpecialization, or if Type is a class and TypeSpecialization is a base class or base interface of it. The Identifier is

What are tuples exactly? (D's tuples considered harmful)

2011-02-25 Thread Morlan
While trying to understand the expand mechanism presented in the TDPL book I tried to read std.typetuple and std.typecons files. I found a true nightmare in those files in the form of an almost infinite chain of aliases and macro processing. How can one understand a written text if the words are

Library reference

2011-02-23 Thread Morlan
I try to read the language reference on http://d-programming-language.org/lex.html but no menu opens on clicking the language reference item, and only one article about lexical conventions is available. There used to be more information there so probably the recent changes (addition of the