{"id":1693,"date":"2018-09-04T14:23:53","date_gmt":"2018-09-04T14:23:53","guid":{"rendered":"http:\/\/dlang.org\/blog\/?p=1693"},"modified":"2021-10-08T11:02:00","modified_gmt":"2021-10-08T11:02:00","slug":"dmd-2-082-0-released","status":"publish","type":"post","link":"https:\/\/dlang.org\/blog\/2018\/09\/04\/dmd-2-082-0-released\/","title":{"rendered":"DMD 2.082.0 Released"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"alignleft size-full wp-image-180\" src=\"http:\/\/dlang.org\/blog\/wp-content\/uploads\/2016\/08\/d3.png\" alt=\"\" width=\"160\" height=\"301\" srcset=\"https:\/\/dlang.org\/blog\/wp-content\/uploads\/2016\/08\/d3.png 160w, https:\/\/dlang.org\/blog\/wp-content\/uploads\/2016\/08\/d3-159x300.png 159w\" sizes=\"(max-width: 160px) 100vw, 160px\" \/>DMD 2.082.0 was released over the weekend. There were 28 major changes and 76 closed Bugzilla issues in this release, including some very welcome improvements in the toolchain. <a href=\"https:\/\/dlang.org\/download.html\">Head over to the download page<\/a> to pick up the official package for your platform and <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html\">visit the changelog for the details<\/a>.<\/p>\n<h2 id=\"toolingimprovements\">Tooling improvements<\/h2>\n<p>While there were several improvements and fixes to the compiler, standard library, and runtime in this release, there were some seemingly innocuous quality-of-life changes to the tooling that are sure to be greeted with more enthusiasm.<\/p>\n<h3 id=\"dubgetsdubbier\">DUB gets dubbier<\/h3>\n<p>DUB, the build tool and package manager for D that ships with DMD, received a number\u00a0 of enhancements, including <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#recursive_dependecy_resolution\">better dependency resolution<\/a>, <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#buildSettingsVars\">variable support in the build settings<\/a>, and <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#env-var-replacement\">improved environment variable expansion<\/a>.<\/p>\n<p>Arguably the most welcome change will be the <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#upgrade_check\">removal of the regular update check<\/a>. Previously, DUB would check for dependency updates once a day before starting a project build. If there was no internet connection, or if there were any errors in dependency resolution, the process could hang for some time. With the removal of the daily check, upgrades will only occur when running <code>dub upgrade<\/code> in a project directory. Add to that the brand new <code>--dry-run<\/code> flag to get a list of any upgradable dependencies without executing the upgrades.<\/p>\n<h3 id=\"signedbinariesforwindows\">Signed binaries for Windows<\/h3>\n<p>For quite some time users of DMD on Windows have had the annoyance of seeing <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_SmartScreen\">a warning from Windows Smartscreen<\/a> when running the installer, and the occasional false positive from AntiVirus software when running DMD.<\/p>\n<p>Now those in the Windows D camp can <a href=\"https:\/\/www.youtube.com\/watch?v=KL19ZVbcPaw\">do a little victory dance<\/a>, as all of the binaries in the distribution, including the installer, <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#signed_windows_binaries\">are signed with the D Language Foundation\u2019s new code signing certificate<\/a>. This is one more quality-of-life issue that can finally be laid to rest. On a side note, the cost of the certificate was the first expense entered <a href=\"https:\/\/opencollective.com\/dlang\">into our Open Collective page<\/a>.<\/p>\n<h2 id=\"compilerandlibraries\">Compiler and libraries<\/h2>\n<p>Many of the changes and updates in the compiler and library department are unlikely to compel anyone to shout from the rooftops, but a handful are nonetheless notable.<\/p>\n<h3 id=\"thecompiler\">The compiler<\/h3>\n<p>One such is an expansion of <a href=\"https:\/\/dlang.org\/spec\/attribute.html#uda\">the User-Defined Attribute syntax<\/a>. Previously, these were only allowed on declarations. Now, <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#uda-function-parameters\">they can be applied to function parameters<\/a>:<\/p>\n<pre class=\"prettyprint lang-d\">\/\/ Previously, it was illegal to attach a UDA to a function parameter\r\nvoid example(@(22) string param)\r\n{\r\n    \/\/ It's always been legal to attach UDAs to type, variable, and function declarations.\r\n    @(11) string var;\r\n    pragma(msg, [__traits(getAttributes, var)] == [11]);\r\n    pragma(msg, [__traits(getAttributes, param)] == [22]);\r\n}<\/pre>\n<p><em><a href=\"https:\/\/run.dlang.io\/is\/Hu4csb\">Run this example online<\/a><\/em><\/p>\n<p>The same goes for enum members (it\u2019s not explicitly listed in the highlights at the top of the changelog, <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#bugfix-list\">but is mentioned in the bugfix list<\/a>):<\/p>\n<pre class=\"prettyprint lang-d\">enum Foo {\r\n@(10) one,\r\n@(20) two,\r\n}\r\n\r\nvoid main()\r\n{\r\npragma(msg, [__traits(getAttributes, Foo.one)] == [10]);\r\npragma(msg, [__traits(getAttributes, Foo.two)] == [20]);\r\n}<\/pre>\n<p><em><a href=\"https:\/\/run.dlang.io\/is\/B2H73i\">Run this example online<\/a><\/em><\/p>\n<p><a href=\"http:\/\/dlang.org\/blog\/2018\/06\/11\/dasbetterc-converting-make-c-to-d\/\">The DasBetterC subset of D<\/a> is <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#betterc_cmp_types\">enhanced in this release with some improvements<\/a>. It\u2019s now possible to use array literals in initializers. Previously, array literals required the use of <code>TypeInfo<\/code>, which is part of DRuntime and therefore unavailable in <code>-betterC<\/code> mode. Moreover, comparing arrays of structs is now supported and comparing arrays of byte-sized types should no longer generate any linker errrors.<\/p>\n<pre class=\"prettyprint lang-d\">import core.stdc.stdio;\r\nstruct Sint\r\n{\r\n    int x;\r\n    this(int v) { x = v;}\r\n}\r\n\r\nextern(C) void main()\r\n{\r\n    \/\/ No more TypeInfo error in this initializer\r\n    Sint[6] a1 = [Sint(1), Sint(2), Sint(3), Sint(1), Sint(2), Sint(3)];\r\n    foreach(si; a1) printf(\"%i\\n\", si.x);\r\n\r\n    \/\/ Arrays\/slices of structs can now be compared\r\n    assert(a1[0..3] == a1[3..$]);\r\n\r\n    \/\/ No more linker error when comparing strings, either explicitly\r\n    \/\/ or implicitly such as in a switch.\r\n    auto s = \"abc\";\r\n    switch(s)\r\n    {\r\n        case \"abc\":\r\n            puts(\"Got a match!\");\r\n            break;\r\n        default:\r\n            break;\r\n    }\r\n\r\n    \/\/ And the same goes for any byte-sized type\r\n    char[6] a = [1,2,3,1,2,3];\r\n    assert(a[0..3] &gt;= a[3..$]);\r\n\r\n    puts(\"All the asserts passed!\");\r\n}<\/pre>\n<p><em><a href=\"https:\/\/run.dlang.io\/is\/FiuBop\">Run this example online<\/a><\/em><\/p>\n<h3 id=\"druntime\">DRuntime<\/h3>\n<p>Another quality-of-life fix, this one touching on the debugging experience, is a <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#exceptions-opt\">new run-time flag that can be passed to any D program<\/a> compiled against the 2.082 release of the runtime or later, <code>--DRT-trapException=0<\/code>. This allows exception trapping to be disabled from the command line.<\/p>\n<p>Previously, this was supported only via a global variable, <code>rt_trapExceptions<\/code>. To disable exception trapping, this variable had to be set to <code>false<\/code> before DRuntime gained control of execution, which meant implementing your own <code>extern(C) main<\/code> and calling <code>_d_run_main<\/code> to manually initialize DRuntime which, in turn, would run the normal D <code>main<\/code>\u2014all of which is demonstrated in the Tip of the Week from <a href=\"http:\/\/arsdnet.net\/this-week-in-d\/2016-aug-07.html\">the August 7, 2016, edition of This Week in D<\/a> (you\u2019ll also find there a nice explanation of why you might want to disable this feature. HINT: running in your debugger). A command-line flag is sooo much simpler, no?<\/p>\n<h3 id=\"phobos\">Phobos<\/h3>\n<p>The <code>std.array<\/code> module <a href=\"https:\/\/dlang.org\/phobos\/std_array.html#array\">has long had an <code>array<\/code> function<\/a> that can be used to create a dynamic array from any finite range. With this release, <a href=\"https:\/\/dlang.org\/changelog\/2.082.0.html#std-array-asStatic\">the module gains a <code>staticArray<\/code> function<\/a> that can do the same for static arrays, though it\u2019s limited to input ranges (which includes other arrays). When the length of a range is not knowable at compile time, it must be passed as a template argument. Otherwise, the range itself can be passed as a template argument.<\/p>\n<pre class=\"prettyprint lang-d\">import std.stdio;\r\nvoid main()\r\n{\r\n    import std.range : iota;\r\n    import std.array : staticArray;\r\n\r\n    auto input = 3.iota;\r\n    auto a = input.staticArray!2;\r\n    pragma(msg, is(typeof(a) == int[2]));\r\n    writeln(a);\r\n    auto b = input.staticArray!(long[4]);\r\n    pragma(msg, is(typeof(b) == long[4]));\r\n    writeln(b);\r\n}<\/pre>\n<p><em><a href=\"https:\/\/run.dlang.io\/is\/7dpxJM\">Run this example online<\/a><\/em><\/p>\n<h2 id=\"septemberpumpkinspice\">September pumpkin spice<\/h2>\n<p><a href=\"https:\/\/dlang.org\/blog\/2018\/02\/03\/the-dbugfix-campaign\/\">Participation in the #dbugfix campaign<\/a> for this cycle was, like last cycle, rather dismal. Even so, I\u2019ll have an update on that topic later this month in a post of its own.<\/p>\n<p>Three of eight applicants were selected for <a href=\"https:\/\/dlang.org\/blog\/symmetry-autumn-of-code\/\">the Symmetry Autumn of Code<\/a>, which officially kicked off on September 1. Stay tuned here for a post on that topic as well.<\/p>\n<p>The blog has been quiet for a few weeks, but the gears are slowly and squeakily starting to grind again. Other posts lined up for this month include the next long-overdue <a href=\"https:\/\/dlang.org\/blog\/the-gc-series\/\">installment in the GC Series<\/a> and the launch of <a href=\"https:\/\/dlang.org\/blog\/d-in-production\/\">a new \u2018D in Production\u2019 profile<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There were 28 major changes and 76 closed Bugzilla issues in this DMD 2.082.0, including some very welcome improvements in the toolchain.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[26,12,27],"tags":[],"_links":{"self":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1693"}],"collection":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/comments?post=1693"}],"version-history":[{"count":15,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1693\/revisions"}],"predecessor-version":[{"id":1708,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/posts\/1693\/revisions\/1708"}],"wp:attachment":[{"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/media?parent=1693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/categories?post=1693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dlang.org\/blog\/wp-json\/wp\/v2\/tags?post=1693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}