new DIP39: Safe rvalue references: backwards compatible, safe against ref/nonref code evolution, compatible with UFCS and DIP38

Timothee Cour thelastmammoth at gmail.com
Fri May 10 19:23:49 PDT 2013


Abstract

We propose to introduce rvalue references that are:
* safe: guarantees memory safety so that references will always point
to valid memory.
* backwards compatible: current valid D code will continue to work
without change. In addition, additional code becomes valid with call
site rvalue ref annotation.
* safe against ref/nonref code evolution: call site rvalue ref
compulsory annotation turns ref/nonref changes into compile errors
instead of silently changing code behavior.
* both const ref or ref can be used with rvalue refs (more flexible than C++)
* no call site ref annotation when input ref argument is already an
lvalue (different from C#), for backwards compatibility (and making it
less verbose)
* compatible with UFCS
* compatible with DIP38: can use same inref/outref internal compiler
annotation for input references that can be returned by ref by a
function. But DIP38 is optional.

link: http://wiki.dlang.org/DIP39


More information about the Digitalmars-d mailing list