On 2009-02-03 02:15:16 -0500, "Nick Sabalausky" <[email protected]> said:
"Nick Sabalausky" <[email protected]> wrote in message news:[email protected]...I had been slowly coming around to the idea of having that universal function syntax instead of C#-style explicit extension methods, but maybe this need for dynamic dispatch is a good reason to prefer explicit extension methods: // As in C#, the "this" means backup() is an extension method void backup(this Node obj, string backupPath) { // base impl } void backup(this File obj, string backupPath) { copy(obj.path, backupPath ~ "/" ~ obj.name); } void backup(this Directory obj, string backupPath) { foreach(child; children) child.backup(backupPath ~ "/" ~ obj.name); } I'm not exactly sure what C# does in this case, but what I'm proposing here is that this could (somehow) cause dynamic dispatch to be used.Out of curiosity, I just did a little test on this in C#. Apperently it doesn't do any dynamic dispatch on this, it just calls the extension method overload for whatever the static type is.
Great. :-) An area where we could surpass C# by just making things work the way they should. Although I'm somewhat doubtful we'll see Walter going away from the simple C++-like vtable design needed for implementing this.
-- Michel Fortin [email protected] http://michelf.com/
