Respond to an unknown method call: Difference between revisions
Content added Content deleted
Line 722: | Line 722: | ||
} |
} |
||
\\ modules, functions numeric and string, and variables can use same name |
\\ modules, functions numeric and string, and variables can use same name |
||
\\ here we have module invoke, |
\\ here we have module invoke, function invoke, and function invoke$ |
||
Module invoke (&a, method$) { |
Module invoke (&a, method$) { |
||
param=(,) |
param=(,) |
||
Line 735: | Line 735: | ||
call "."+method$, !param |
call "."+method$, !param |
||
} |
} |
||
} else Flush : Error " |
} else Flush : Error "unknown method "+method$ ' flush empty the stack |
||
} |
} |
||
Function invoke (&a, method$) { |
Function invoke (&a, method$) { |
||
Line 747: | Line 747: | ||
=Function("."+method$, ![]) |
=Function("."+method$, ![]) |
||
} |
} |
||
} else Error " |
} else Error "unknown Function "+method$ |
||
} |
} |
||
\\ invoke string functions |
\\ invoke string functions |
||
Line 761: | Line 761: | ||
=Function$("."+method$, ![]) |
=Function$("."+method$, ![]) |
||
} |
} |
||
} else Error " |
} else Error "unknown Function "+method$ |
||
} |
} |
||
Line 775: | Line 775: | ||
\\ this method has a weak reference to obj, so anytime we use This. or just dot, this weak reference make the real name to execute |
\\ this method has a weak reference to obj, so anytime we use This. or just dot, this weak reference make the real name to execute |
||
Obj.a 10,20 |
Obj.a 10,20 |
||
\\ call the fake method (can't access object methods |
\\ call the fake method (can't access object methods and properties), has empty weak reference to object |
||
obj.alfa 10, 20 |
obj.alfa 10, 20 |
||
Line 781: | Line 781: | ||
\\ to check if a method (module) exist, we have to compare this object with other temporary object |
\\ to check if a method (module) exist, we have to compare this object with other temporary object |
||
\\ we make one with the method name and empty definition, and then check if obj has anything this temp object has |
\\ we make one with the method name and empty definition, and then check if obj has anything this temp object has |
||
\\ arguments passed in a tuple (optional), so we didn't leave stack with unused items, if we have an |
\\ arguments passed in a tuple (optional), so we didn't leave stack with unused items, if we have an unknown method. |
||
invoke &obj, "a", (10, 20) |
invoke &obj, "a", (10, 20) |
||
invoke &obj, "NoParam" |
invoke &obj, "NoParam" |