On Tuesday, August 30, 2011 03:44:33 Stephan Soller wrote:
> On 27.08.2011 19:16, Benjamin Thaut wrote:
> > After having used the D 2.0 programming language for a year now and
> > having completed 3 projects with it, I wrote a small article about the
> > problems I had with the D 2.0 programming language and what suggestions
> > I have to improve it.
> > 
> > http://3d.benjamin-thaut.de/?p=18
> > 
> > Comments and criticism welcome
> 
> As for point no. 3 (Structs not having identity):
> 
> Structs have a postblit constructor. These have access to the new struct
> but not the old one. Maybe you can use this to register a new reference.
> If I remember this right the old reference should be cleaned up
> (unregistered) by the destructor but I'm not sure. You article implies
> that the destructor is not called for every copy of the struct.

It's not called on _moves_. In a number of cases, the compiler moves a struct 
via a bitwise copy rather than actually copying it (which would involve 
calling the postblit constructor and the destructor). When that happens, the 
address of the struct changes. And since he was doing something where he was 
keeping track of the structs based on their addresses on the stack, it messed 
up his tracking. So, he can't really do what he's trying to do the way that 
he's trying to do it.

> Point no. 8, "No function overloading with template parameters":
> 
> Got the same problem while templating some functions of an overload set.
> It's not possible to mix overloads with templates. That wasn't much of a
> problem but converting everything to templates doesn't work ether. In
> the end I used templates that generate normal function overloads and
> explicitly instantiated those templates.

You can often add empty parens to templatize a function  - e.g. int func()(int 
i) - to get around the problem without really changing your function. But it's 
definitely true that allowing overloads between templatized and non-templatized 
functions would be an improvement. Hopefully, we get it at some point.

- Jonathan M Davis

Reply via email to