On 2/3/14, 6:07 AM, Kenji Hara wrote:
2014-02-03 Andrei Alexandrescu <seewebsiteforem...@erdani.org
<mailto:seewebsiteforem...@erdani.org>>:
Here are a few questions and comments:
First of all, thanks for your reviewing!
And thank you for your work and this reply.
This part:
Note that, currently D has 9 qualifiers:
- (mutable)
- const
- inout
- inout const (added from 2.065. See issue 6930)
- shared
- shared const
- shared inout
- shared inout const (added from 2.065. See issue 6930)
- immutable
So, if we allow defining arbitrary postblit from A to B copy, you can
define 9 * 9 = 81 postblits!
I don't want to see such horrible D code.
convinced me something has definitely gotten out of hand. We must devise
a radically simpler solution to object copying, one that aims straight
at solving the fundamental problems we're facing. Far as I can tell
these are it:
1. Reference counting for all objects, including const/immutable/shared.
If this(this) can't be reasonably made to solve that, we will build it
into the language and raise the question whether this(this) should exist
at all. In particular, calling .dup inside this(this) is an antipattern.
Objects must be cheap to copy. So any example using somrArray.dup inside
this(this) is an instant indication we're solving the wrong problem (and
with a wrong solution as well).
2. Removing head const. You have added the nice conversion
qualified(T[]) -> qualified(T)[] upon calling a function. We must look
at ways to allow the user a similar generalization for type constructors.
If we figure this(this) doesn't help these two problems, its entire
existence must be put in question.
Andrei