std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]

Andrei Alexandrescu SeeWebsiteForEmail at erdani.com
Mon Jun 22 16:42:55 UTC 2020


On 6/22/20 12:14 PM, Paul Backus wrote:
> Making it work in general requires either subverting the type system 
> (like Rebindable does) or adding more special cases to the language.

The principled approach is to generalize the trick currently used only 
for arrays. Consider the lowering:

"Whenever something is passed to a function, .opOnCall is appended."

Then:

auto ref T opOnCall(T)(auto ref T x) { return x; }
const(T)[] opOnCall(T)(const(T[]) x) { return x; }
immutable(T)[] opOnCall(T)(immutable(T[]) x) { return x; }

This is just a sketch, haven't thought it through, but if properly 
defined the scheme would work having built-in arrays work as they are 
today, and would also allow user-defined types to define their own 
opOnCall as they find fit.


More information about the Digitalmars-d mailing list