Challenge: write a reference counted slice that works as much as possible like a built-in slice
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.com
Thu Nov 11 21:46:29 UTC 2021
On 2021-11-08 19:12, H. S. Teoh wrote:
> On Mon, Nov 08, 2021 at 10:15:09PM +0000, deadalnix via Digitalmars-d wrote:
> [...]
>> I think however, you missed several massive problems:
>> 4. Type qualifier transitivity. const RCSlice!T -> const
>> RCSlice!(const T) conversion needs to happen transparently.
>
> The only way this can happen is via a language change. The only way
> arrays get to enjoy such benefits is because the necessary implicit
> conversion rules are baked into the language. User-defined types do not
> have such privileges, and there is currently no combination of language
> constructs that can express such a thing.
I keep on thinking of proposing opFunCall() that is called whenever an
object is passed by value into a function. The lowering for such objects
would be:
fun(obj);
===>
fun(obj.opFunCall());
More information about the Digitalmars-d
mailing list