Talk:Respond to an unknown method call: Difference between revisions

→‎Go solution: new section
m (Mistypes)
(→‎Go solution: new section)
 
Line 53:
::::::::: The general database classes don't know and don't care about the GUI. No need to define proxy or dispatch classes. Only those concrete classes which should actually respond to these messages need to implement a method for them.
::::::::: In PicoLisp, a method can be defined on-the-fly, for a single object or a class. The code for that definition must not reside in the same source file as the original class, but can be local to the application. --[[User:Abu|Abu]] 08:37, 8 November 2011 (UTC)
 
== Go solution ==
 
I'm hoping this satisfies the intent of the task. It does not catch the unknown method at compile time, it does not throw an exception, it does not force the caller to check for the existance of the method nor force the caller to handle the absence of the exception. The caller calls a method on an object, and then it is that method, a method of the receiving object, that handles the absense of the requested method. Defining a CallMethod method seems much like what is done in some other languages when a handler is defined to handle unknown method calls.
 
The remaining variance which might invalidate the solution is that the method isn't called directly. Go has no syntax for, <pre>object.<expression that evaluates to a method>()</pre> Thus the neccessity of the CallMethod method. &mdash;[[User:Sonia|Sonia]] 21:37, 15 February 2012 (UTC)
1,707

edits