dcollections ArrayList conating array of classes/structs
Hi, IMHO ArrayList has a bug. Just declaring ArrayList!B bl, raises an error. But maybe I am wrong.. Nevertheless I 've filed a ticket. In case that I switch from class to struct also std.algorithm is involved. class AListTest { alias ArrayList!B BList; BList bl; this() {} } class B { string _name; this(string name) { this._name = name; } } Error 1 Error: cannot implicitly convert expression (this._array[0u]) of type const(B) to main.B D:\dmd2\windows\bin\..\..\src\phobos\dcollections\ArrayList.d 772 Error 2 Error: cannot implicitly convert expression (this._array[__dollar - 1u]) of type const(B) to main.B D:\dmd2\windows\bin\..\..\src\phobos\dcollections\ArrayList.d 780
Re: Mixing operations with signed and unsigned types
Stewart Gordon: what you seem to be suggesting is that size_t be the same as ptrdiff_t. Yes, but an unsigned word type needs to be kept in the language. There is, however, another problem: signed types convert implicitly to unsigned types, though they do generate a warning if compiled with -w (except peculiarly for int/uint). Removing this implicit conversion would break certain existing code that uses signed types where it should be using unsigned. If we also change array indices to be signed, it would break that code that sensibly uses unsigned types, which is probably worse. Yes, of course that code needs to be fixed after the change I have suggested. A breaking change means that some of the old code needs to be fixed. Bye, bearophile
Re: Class knowing its own Class
Dnia 30-06-2010 o 00:13:28 strtr st...@sp.am napisał(a): == Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article On Tue, 29 Jun 2010 17:59:37 -0400, strtr st...@sp.am wrote: What is the pretty way to do something like this? Class C { void makeNew() { new typeof(this); } } As edited... -Steve Whahaha! Thanks, I knew I was missing something here. Interestingly, this works even if makeNew is static (as factory methods usually are). Don't know whether by design or by bug. If by the latter, please don't fix it ;) Tomek
Re: Mixing operations with signed and unsigned types
bearophile wrote: Stewart Gordon: snip If we also change array indices to be signed, it would break that code that sensibly uses unsigned types, which is probably worse. Yes, of course that code needs to be fixed after the change I have suggested. A breaking change means that some of the old code needs to be fixed. That code needs to be fixed? My point was that being forced to use signed types for values that cannot possibly be negative doesn't to me constitute fixing anything. Stewart.