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.


I've always felt very suspicious of opDispatch. It seems like exactly
the kind of thing that seems good when you look at simple cases, but
would cause subtle problems when used in conjunction with other D
features (e.g. UFCS).

I'm not yet convinced that opDispatch has been thoroughly explored
enough to be used in such a fundamental part of the standard library.

There are several uses for opDispatch. For example, vector swizzling is
an example of using opDispatch to replace a finite set of related
functions. General forwarding, like alias this, requires a minimalistic
design: the public interface should be as small as reasonable and the
private functions should never use a 'good' function name.

Stuff like swizzling is fine because you are just using it to generate other functions. Forwarding is what worries me because it has to cover absolutely *everything* and avoid namespace clashes in order to be useful.

Reply via email to