Fully dynamic d by opDotExp overloading
Simen Kjaeraas
simen.kjaras at gmail.com
Sun Apr 19 04:08:04 PDT 2009
Adam Burton wrote:
> What about using something like '->' for dynamic calls instead of '.'?
> When
> you see '.' your safe in the knowledge that at a glance you know said
> method
> with said signature exists else the compiler will throw a paddy, when you
> see '->' you know that method call is evaluated at runtime. This has the
> added benefit that the same class can be used in compile time checking
> code
> and runtime.
One use I can see for this is the other opDotExp use that's been mentioned in this thread, namely:
struct s {
opDotExp( string s ) { ... }
}
s obj;
auto command = readInput();
obj->command( ); // calls obj.opDotExp( command )
For message-passing, one could argue that <- would be better than ->, though there are ambiguity problems with that.
--
Simen
More information about the Digitalmars-d
mailing list