Upgrading a codebase from 2.065 to 2.066

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 2 16:11:56 PDT 2014


On Wed, Jul 02, 2014 at 10:50:21PM +0000, bearophile via Digitalmars-d wrote:
> Brian Schott:
> 
> >I recently upgraded EMSI's internal data processing library[1] so
> >that it will be compatible with the upcoming 2.066 release and
> >thought it might be useful to share my experience.
> 
> I suggest to update large programs more frequently than adjacent
> compiler versions, because there is too much changed stuff.

This may not be practical if your codebase is production, and relies on
the compiler being (relatively) stable. Sometimes things break in a
major way on git HEAD in between releases and get fixed later, so you
might end up spending unnecessary effort to make your code compile every
few git revisions.


> >5. A change to object.d broke a line of code that used "[]" as the
> >"defaultValue" argument to the get() function for AAs. Casting "[]"
> >to the expected type worked around this issue.
> 
> Indeed this doesn't compile, but perhaps it should:
> 
> void main() {
>     int[][int] aa;
>     int[] r = aa.get(0, []);
> }
> 
> 
> A current workaround (but it's not DRY, because 'aa' is repeated twice):
> 
> void main() {
>     import std.traits: ValueType;
>     int[][int] aa;
>     int[] r = aa.get(0, ValueType!(typeof(aa)).init);

You *could* just write this, y'know:

    int[] r = aa.get(0, aa[0].init);

:) Still not completely DRY, but less typing. You don't need to refer to
the type of the element in order to get its .init value.


T

-- 
Right now I'm having amnesia and deja vu at the same time. I think I've forgotten this before.


More information about the Digitalmars-d mailing list