Peter Duniho wrote:
In C#:

   void setColor(NSColor color)
   {
       undoManager.prepareWithInvocationTarget(this).setColor(mColor);
       mColor = color;
   }

Your point being? If you think your example is useful in presenting your claim, you'll need to be a lot more specific.

[...]
Well, I'm still waiting for someone to show me how that flexibility is used. You are certainly doing a great job of stating the same party line I've heard countless times already. But you're also failing to provide a compelling example of how this flexibility comes into play in the real world. Again, this is not only typical, it's characteristic of _every_ single time I've heard the party line stated.

You've translated the Objective-C syntax into C# syntax, but the point of the question is to think about what prepareWithInvocationTarget() does. How would you write that method in C#?

In Objective-C, after you call -prepareWithInvocationTarget: on an NSUndoManager, it then accepts _any_ message call of any kind. It is completely and totally dynamic. It accepts messages from your application which weren't defined and didn't exist when the NSUndoManager class was compiled. The undo manager accepts the message, saves the target and method invocation with an arbitrary number of arguments and is able to re-invoke it later on the original target when the user asks you to Undo.

This is an example of what a dynamic message dispatch mechanism can do for you. How would you implement that in a direct invocation or v- table environment? Of course Undo is still doable in Java or C#: these are all turing equivalent languages, but how much code would it take and how complicated would it be for the programmer using the undo management library to define this-is-something-to-undo?

Hope this helps,
        - Greg


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to