digitalmars.D - Experience upgrading template code from 2.065 to 2.067
- simendsjo (39/39) Jul 22 2015 I updated a small template-heavy experimental library mostly for
- Nicholas Wilson (2/6) Jul 23 2015 I'm assuming thats a typo
- simendsjo (3/9) Jul 23 2015 Yes. I just wrote the code in the post without trying to compile
- Jacob Carlborg (4/5) Jul 23 2015 caching -> catching :)
I updated a small template-heavy experimental library mostly for compile-time introspection I write some time ago. The last time I updated the code was probably using 2.065, but might also have been as old as 2.063. The code doesn't use much of the standard library, mostly parts of std.traits and std.typetuple.TypeTuple. While upgrading, I only encountered a single bug (https://issues.dlang.org/show_bug.cgi?id=14820), which might have been there for a long time as I didn't check when it was introduced - I hit it when adding additional unittests when I got weird compile-time errors. There was however a breaking change that caused most of my templates to fail. My templates supports both built-in types, user-defined types and values. In order to do this, both templates of `T` and `alias T` has to be created. In previous versions of the compiler, user-defined types always picked the `alias T` version first, while the newest compiler picks `T` for all types. I found the old behavior pretty weird, so I'm all in favor of the change though. // 1 template Tmlp(T) {} // 2 template Tmpl(alias T) {} struct S {} Tmpl!S; // 2 on 2.065 (/2.063?), 1 on 2.067 There's still an odd difference between built-in and user-defined types: template OnlyAlias(alias T) {} struct S {} OnlyAlias!S; // works OnlyAlias!int; // doesn't work I also had to make some dub related changes and a simple import because `chain` moved from `std.algorithm` to `std.range`. Just a little experience-report for upgrading between compiler versions. I'm one of the people that is pro breaking-changes. Keep in mind that this is a small project of just 4351 LOC where a lot is tests and documentation and nearly no use of phobos or druntime. Anyway - happy to see breaking changes that improves the language.
Jul 22 2015
On Wednesday, 22 July 2015 at 15:50:13 UTC, simendsjo wrote:// 1 template Tmlp(T) {} // 2 template Tmpl(alias T) {}I'm assuming thats a typo
Jul 23 2015
On Thursday, 23 July 2015 at 13:20:32 UTC, Nicholas Wilson wrote:On Wednesday, 22 July 2015 at 15:50:13 UTC, simendsjo wrote:Yes. I just wrote the code in the post without trying to compile it. I'm not as good at caching typos as the compiler.// 1 template Tmlp(T) {} // 2 template Tmpl(alias T) {}I'm assuming thats a typo
Jul 23 2015
On 2015-07-23 15:58, simendsjo wrote:I'm not as good at caching typos as the compiler.caching -> catching :) -- /Jacob Carlborg
Jul 23 2015