It turns out the docs [1] try to explain how it works:
> The method finder will take the input objects (receiver and arguments) and perform their permutation to be able to find more results.
Then, it will lookup in the receiver's hierarchy the approved and forbidden methods to run on the hierarchy and run them on the permutation of objects.
which sounds like an exhaustive search.
I dug a little further and found this [2] which points to the actual implementation in the `MethodFinder` class. I don't know enough Smalltalk to decipher it :(
- ask the receiver class (in the example above, the class of 2, which is something like SmallInteger) for "all the selectors (= method names) to test" with the given number of arguments.
- for each of these methods, build a MethodFinderSend object, which is at this point is just a container holding a copy of the receiver object, the method to call on it, and a copy of the arguments to test with
Then, given this collection of MethodFinderSend objects:
- otherwise, return true or false depending on whether the result equals the expected result
So yes, it's an exhaustive search over the methods that the receiver's class promises are OK to test. If you write a method that tries to format the hard drive, and your class exports this method in its "selectors to test", then searching for a method on this class will attempt to format your hard drive.
Not as far as I know. In fact, the system prides itself on allowing you to modify everything in it.
One striking demo I saw once a few years ago (so details are a bit hazy) involved the become: message. This is a special operation for swapping references around. "X become: Y" has the effect of everything that previously referred to X to now refer to Y, and everything that previously referred to Y to refer to X.
So the demo was to execute something like:
White become: Black.
which immediately switched all white pixels to black and vice versa.
I think the person giving the demo even demonstrated
True become: False.
though that made the VM unusable pretty much immediately IIRC.
> The method finder will take the input objects (receiver and arguments) and perform their permutation to be able to find more results. Then, it will lookup in the receiver's hierarchy the approved and forbidden methods to run on the hierarchy and run them on the permutation of objects.
which sounds like an exhaustive search.
I dug a little further and found this [2] which points to the actual implementation in the `MethodFinder` class. I don't know enough Smalltalk to decipher it :(
[1] https://github.com/pharo-open-documentation/pharo-wiki/issue...
[2] https://csharp.developreference.com/article/18692966/How+doe...