Persistent list

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 16 13:18:13 PST 2015


On Monday, 16 November 2015 at 20:48:49 UTC, Andrei Alexandrescu 
wrote:
> I think we should slowly marginalize inout - discourage it from 
> new code, document and publicize better alternatives, the works.

When you can templatize the function on the type that would 
otherwise be inout, then there really isn't any reason to use 
inout. But what do you do when you're dealing with a member 
function - especially on a class? I don't know of any way to 
templatize a member function on the type of the this 
pointer/reference, but maybe there's a template feature with 
which I'm not familiar enough. But even if there _is_ such a 
feature, it won't work for virtual functions.

So, while I completely agree that it's cleaner to avoid inout 
when it's not needed, from what I can see, there are cases where 
you really don't have an alternative aside from duplicating the 
entire function. So, it does seem like on some level, we're stuck 
using inout, even if we can avoid it in many cases.

- Jonathan M Davis


More information about the Digitalmars-d mailing list