Time to kill T() as (sometimes) working T.init alias ?
deadalnix
deadalnix at gmail.com
Mon Dec 10 11:30:51 PST 2012
On Monday, 10 December 2012 at 16:52:54 UTC, monarch_dodra wrote:
> The talk deviated to postblit, but in the original argument,
> the entire point of the thread is to have extra support for
> reference-type objects: Objects that are basically nothing more
> than a pointer. You'd have a hard time doing cheaper copy than
> that actually.
>
The postblit discussion is very relevant here.
The underlying point is the concept of ownership. When a
structure contains a reference, it may own the data refered, or
not.
The existence of postblit allow for struct that own their data
(by default in they don't). But the struct can't assert in a
first place that it own the data. It may only hope that the user
did things right in the first place and act as if it does own the
data. In addition, the struct have to check all over the place
that owned data does exists, because it has no way to ensure they
do.
The point that disallowing default constructor, and allowing
postblit is inconsistent. One is made for a concept that is
broken by the lack of the other. If it is really decided that
ownership is a BAD THING©, then we should disable both postblit
and default construction.
COW isn't a valid replacement, because it imply different
tradeoff. It is good for an object that is copied a lot and not
modified often (or have an expensive modification). Ownership
goes the other way around : it is good for an object that isn't
copied often, but get a lot of cheap modifications.
More information about the Digitalmars-d
mailing list