DConf 2013 Day 1 Talk 2 (Copy and Move Semantics)

H. S. Teoh hsteoh at quickfur.ath.cx
Fri May 10 22:03:31 PDT 2013


Woohoo, Ali's talk is up! Just finished watching it. I have to thank Ali
for a most excellent presentation. Very informative and insightful, and
I learned several really cool things about D that I wasn't even aware of
before:

- to!string doesn't copy when the source is already a string 'cos it's
  immutable. Sweeeet!

- The bit about swapping of structs when assigning a function's return
  value. Makes a lot of sense semantically! Though it does bear looking
  into for further optimizations. What about in-place construction if a
  struct is known to be returned to the caller, so that even the move is
  elided?

- The bit about exception-safe ctors: awesome!! Yet another thing D gets
  right, that blows up in C++.

- Implicit casting to immutable from return value of pure functions --
  that is absolutely awesome, and as Walter said, yes we should
  definitely explore this more. Looks like we can have our cake and eat
  it too!

- The idiom of using this(S that) vs. this(ref const(S) that) for
  move/copy: another awesome idiom that should be documented in a
  prominent place so that more people are aware of it.


T

-- 
Questions are the beginning of intelligence, but the fear of God is the beginning of wisdom.


More information about the Digitalmars-d mailing list