OpenD update - null pointer error shipped, among others
Adam D. Ruppe
destructionator at gmail.com
Tue Jun 10 13:19:42 UTC 2025
Been a while since I posted here, but thought you might be
interested in an update.
OpenD continues to ship its rolling release with a focus on
stability and common sense incremental improvements to the user
experience.
Among the recent changes (very few of which break your existing
code!) <https://opendlang.org/changes.html>:
* Most pointer operations are automatically checked for `null`,
and throw NullPointerError instead of faulting the process. More
info here:
https://dpldocs.info/this-week-in-d/Blog.Posted_2025_06_09.html#nullpointererror
Note that many other pointer operations require `@system` to
ensure you aren't accidentally misusing them as part of OpenD's
"safer by default".
* Stack traces are abbreviated, trying to focus on relevant info.
https://dpldocs.info/this-week-in-d/Blog.Posted_2025_05_26.html
* `with(auto x = thing) { ... }` works.
* `__module` supported in ImportC, so you can make a better
integrated C bridge file.
* Heredoc strings have automatic outdenting, similar to C#. See:
https://dpldocs.info/this-week-in-d/Blog.Posted_2025_02_20.html#outdenting-heredoc-strings
* `import("file")` will just work if file is located next to the
source file.
* `static foreach(...) static if(is(X Y)) ...` works without
redefined identifier errors.
* Tuple destructuring works.
```
// unpack declarations
auto (a, (b, c)) = t(1, t(2, "3"));
assert(t(a, b, c) == t(1, 2, "3"));
```
* `foreach(int a, item; some_array)` works, it puts out a runtime
assert that some_array.length fits in an `int` so you don't have
to cast.
* `pragma(explicit_gc)` lets you trigger nogc checks locally but
still call other gc functions if you want.
And I think I already posted here about some of these older
changes, but among other things that shipped more like a year ago:
* OpenD IES permits `i"$foo"`, without parenthesis around simple
interpolated variable names.
* We ship dmd and ldc together, built from the same codebase, so
features come on both at the same time.
* The compiler prohibits mutable data in static initializers, so
```
class A {
int[] a = [1, 2, 3];
}
A obj = new A;
obj.a[0] = 0;
A obj2 = new A;
assert(obj.a[0] == 0); // this is the case upstream, but
opend will make you clarify your intent with an attribute or
point you toward putting the initialization in a constructor.
```
* Easy cross-compilation to Windows and browser via Emscripten
(requires installing emscripten from their website). Likely more
coming soon.
https://dpldocs.info/this-week-in-d/Blog.Posted_2024_10_25.html
for shipped info and
https://dpldocs.info/this-week-in-d/Blog.Posted_2025_06_09.html#other-experimentation for likely next steps.
* `private(this)` is available to move the privacy barrier to the
class rather than the module if you need it.
* Lots of old bugs in dmd have been fixed in opend including one
with classes inheriting from abstract classes that require
interfaces crashing at runtime instead of being a compile error,
`-lib` and `-shared` filenames being broken.
* extern(Objective-C) and `@section` works on both compilers. You
might have seen the Objective-C stuff as it also shipped in
upstream ldc (thanks Luna for doing the backport and fixing a
couple bugs I missed!).
And more. These are generally little things that just now work
the way you'd expect they always should have, so it is easy for
me to even forget the changes!
You can always download the latest rolling release from here:
https://github.com/opendlang/opend/releases/tag/CI
And to keep up on changes, I try to update my blog about once a
month with a summary of changes:
https://dpldocs.info/this-week-in-d/Blog.html
More information about the Digitalmars-d-announce
mailing list