2 ms·
Consider that someob.foo(other args) in C++ is already effectively syntactic sugar for <address of foo as function pointer>(someob, other args) where <address o
by vidarh 12y ago
Consider that someob.foo(other args) in C++ is already effectively syntactic sugar for <address of foo as function pointer>(someob, other args) where <address of foo> is either obtained by statically resolving which function "foo" refers to, or dynamically looking it up in "someob"'s vtable with an indirection.
What we've always had is two syntaxes that results in pretty much the same code (the same for non-virtual member functions and freestanding functions, and slightly different for virtual member functions) that have mainly different by lookup.
This proposal is basically suggesting to reduce the gap by making the "dot syntax" closer to a superset of the function call lookup.
I don't see how that is any more confusing than any number of basic C++ semantics, and it has some fairly substantial benefits, in that it e.g. allows people to write libraries to "extend" the apparent interface of a class without forcing users to use two entirely different syntaxes.
Just being able to turn instances of baz(bar(foo(ob))) into ob.foo().bar().baz() would be worth it to me.
- phkahler 12y ago>> Just being able to turn instances of baz(bar(foo(ob))) into ob.foo().bar().baz() would be worth it to me. That's funny because I thought he was trying to suggest nobody use the . notation any more, while you give a nice example of going the other way.