Reference counted containers prototype

Robert Jacques sandford at jhu.edu
Mon Dec 26 23:00:41 PST 2011


On Mon, 26 Dec 2011 17:30:54 -0800, Peter Alexander <peter.alexander.au at gmail.com> wrote:

> On 27/12/11 1:14 AM, Robert Jacques wrote:
>> On Mon, 26 Dec 2011 17:09:02 -0800, Peter Alexander
>>> If the held object has a method with the same name as RefCounted (e.g.
>>> asConst) then how do you call the held object's method instead of
>>> RefCounted's method?
>>
>> You, can't. Looking at the source code asConst is a private member
>> function and therefore, given we are using opDispatch for forwarding,
>> these methods should have _ or __ prepended onto them.
>
> Identifiers starting with __ are reserved, which leaves you with _,
> which could be used by the held object also.

Yes, in theory, but no in practice. It's perfectly possible to use __name or __name__ in user code, just highly not recommended. And while I'd never do that in my user code, I think the runtime and the standard library should be able to use __ (or maybe ___) when needed.


More information about the Digitalmars-d mailing list