On Thu, 08 Mar 2012 15:06:19 -0500, H. S. Teoh <hst...@quickfur.ath.cx>
wrote:
On Thu, Mar 08, 2012 at 02:50:50PM -0500, Steven Schveighoffer wrote:
On Thu, 08 Mar 2012 14:49:12 -0500, H. S. Teoh
<hst...@quickfur.ath.cx> wrote:
>On Thu, Mar 08, 2012 at 08:22:05PM +0100, Timon Gehr wrote:
[...]
>>inout(Slot)* findSlot(Key key) inout { ... }
>
>Ahhh. Thanks!
>
>But that still doesn't solve the problem:
>
> inout(Slot)* findSlot(Key key) inout {
> auto slot = slots[hash(key)];
What is type slot, and how is it constructed? This snippit isn't
enough to provide help.
[...]
Slot is a struct, and slots is Slots*[]. But anyway, I found the
problem. I needed to explicitly declare slot as:
inout(Slot)* slot = ...
because for whatever reason, auto turns it into inout(Slot*) which
cannot be modified.
I was wondering, because your error message identified it as inout(Slot)*,
which should be modifiable...
I think inout is one of those things that really needs more thorough
treatment for newbies, because coming from a C/C++ background I had no
idea what was wrong. Now that I get it, it makes so much more sense.
It's kind of a new concept to D even (since 2.056). It's not completely
fleshed out yet, Timon, Kenji, and Stuart have some great ideas on making
it better.
This article might help: http://drdobbs.com/blogs/cpp/231902461
I plan to write a const/inout article at some point.
-Steve