Skip to content
0:00 / 0:00

#dlang#copysemantics#movesemantics

DConf 2013 Day 1 Talk 2: Copy and Move Semantics in D by Ali Cehreli

Andrei Alexandrescu

683 subscribers • 1 video on Hallway

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • Presented by Ali Cehreli

Advanced. Deep dive for people who know the field.

4.9K views13 years ago1 recommendation

Programming languagesSystems programmingLanguage design and type systemsMemory management

Ali Cehreli explains copy and move semantics, const, and immutability in the D programming language.

This talk is part of the D Programming Language Conference, May 1-3 2013, Menlo Park, CA. Slides available at dconf.org/2013/talks/cehreli.pdf. For more information refer to dconf.org/2013/talks/cehreli.html.

Why it's here

1 person recommends this

What people say. Recommended as an excellent presentation on how const and immutability work in D.

Mihails Strasunson Stack Overflow • Recommends

On “When and how should I use `const` and `immutable` in D?”

You are extremely lucky - a video from DConf2013 with presentation devoted exactly to this topic has been published last week : link to this video In your case, auto s = new immutable(S)(); should do the trick. You can then create data slice points to in constructor. However, if this slice may point to any data, then S can't possibly be immutable, because both const and immutable are transitive in D - they provide very strong guarantees not only about variable itself but also about any data that can be accessed from it indirectly via reference/pointer. It is actually covered in linked video, but short summary is that you want to use immutable when really intend to. In other words, when you want you…