On Thursday, 8 May 2014 at 03:58:16 UTC, Andrei Alexandrescu wrote:
This change would allow library designers to provide good solutions to making immutable and const ranges work properly - the way T[] works.

There are of course a bunch of details to think about and figure out, and this is a large change. Please chime in with thoughts. Thanks!

Andrei

The only thing I'd be afraid about is calling a run-time *function* when you pass something by value. It seems like it creates a *huge* hole for abuse.

I'd be OK if "opByValue" was allowed only as an alias type. EG, something like:

struct S(T)
{
    alias opByValue(const) = S(const(T));
}

Which would (statically) mean that "const(S(T))" may (and should) be value converted to S(const(T));

This would still need a bit of work, but I think having a hidden function call for pass by value is a Bad Thing (tm)

Reply via email to