On 12/27/11 9:27 AM, Michel Fortin wrote:
On 2011-12-27 14:57:18 +0000, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:
I talked a lot about this with Walter and we concluded that the story
with const and immutable goes like this: in a RefCounted!T object, the
T is constant, not the RefCounted. So it would be
RefCounted!(immutable T).

That'll work, but I'm not sure where you're getting at with this.

Instead of writing "const DList!T" as the parameter type in your
function you have to write "RefCounted!(const DListImpl!T)"? Isn't that
worse than "ref const DList!T"?

That's an issue we're thinking about how to address.

Not to seem dismissive, but this sounds quite complicated for what it
does. Could we implement it as a library feature? And assuming your
motivating argument wasn't as strong, is it needed?

It can't be a library feature because it requires the compiler to
implicitly add a "ref" to functions parameters when they are of a "ref
struct" type. That's pretty much all it does: add a flag to struct
types, implicitly add "ref" to parameters based on that flag.

Anyhow, I think a feature would need to be tremendously justified and with a huge power/weight ratio. This one I actually find ill-designed because now I can't look at the body of a function to figure pass-by-value vs. pass-by-reference - I also need to look at the definition (what if it was a ref struct?). One more non-modular thing to keep in mind. This is not going to fly.

I'm not sure why you think it's complicated. Perhaps I should just not
have talked about rvalues: that's a separate benefit you can built on
top of it by adding one or two lines of code in DMD, but it's a separate
thing.

I think the "But there's one more thing" did it to me.


Andrei


Reply via email to