Squeak Class Documentation category index | class index  
 
MethodFinder
  category: Kernel-Methods
  superclass: Object
  subclasses:

Find a method in the system from a set of examples. Done by brute force, trying every possible selector. Errors are skipped over using ( [3 + 'xyz'] ifError: [^ false] ).
Submit an array of the form ((data1 data2) answer (data1 data2) answer).

MethodFinder methodFor: #( (4 3) 7 (0 5) 5 (5 5) 10).

answer: 'data1 + data2'

More generally, use the brace notation to construct live examples.

The program tries data1 as the receiver, and
tries all other permutations of the data for the receiver and args, and
tries leaving out one argument, and
uses all selectors data understands, and
uses all selectors in all od data's superclasses.

Floating point values must be precise to 0.01 percent, or (X * 0.0001).

If you get an error, you have probably discovered a selector that needs to be removed from the Approved list. See MethodFinder.initialize. Please email the Squeak Team.

Only considers 0, 1, 2, and 3 argument messages. The argument data may have 1 to 5 entries, but only a max of 4 used at a time. For now, we only test messages that use given number of args or one fewer. For example, this data (100 true 0.6) would test the receiver plus two args, and the receiver plus one arg, but not any other patterns.

Three sets of selectors: Approved, AddAndRemove, and Blocks selectors. When testing a selector in AddAndRemove, deepCopy the receiver. We do not handle selectors that modify an argument (printOn: etc.). Blocks is a set of (selector argNumber) where that argument must be a block.

For perform, the selector is tested. It must be in the Approved list.

do: is not on the Approved list. It does not produce a result that can be tested. Type 'do' into the upper pane of the Selector Finder to find messages list that.

[Later, allow the user to supply a block that tests the answer, not just the literal answer.]
MethodFinder methodFor: { { true. [3]. [4]}. 3}.
Later allow this to work without the blocks around 3 and 4.

instance methods
  access
  answers
data
expressions
selectors

  arg maps
  argMap
makeAllMaps
mapData
permuteArgs
thisData

  find a constant
  allNumbers
const
constDiv
constEquiv
constLinear
constMod
constMult
constPlus
constUsingData1Value

  initialize
  cleanInputs:
copy:addArg:
initialize
initialize2
initialize3
load:
noteDangerous
organizationFiltered:
test2:
test3
testFromTuple:
testRandom
verify

  search
  exceptions
findMessage
insertConstants
search:
searchForOne
simpleSearch
testPerfect:

class methods
  as yet unclassified
  methodFor:

instance methods
  access top  
 

answers


 

data


 

expressions


 

selectors

Note the inst var does not have an S on the end


  arg maps top  
 

argMap


 

makeAllMaps

Make a giant list of all permutations of the args. To find the function, we will try these permutations of the input data. receiver, args.


 

mapData

Force the data through the map (permutation) to create the data to test.


 

permuteArgs

Run through ALL the permutations. First one was as presented.


 

thisData


  find a constant top  
 

allNumbers

Return true if all answers and all data are numbers.


 

const

See if (^ constant) is the answer


 

constDiv

See if (data1 // C) is the answer


 

constEquiv

See if (data1 = C) or (data1 ~= C) is the answer


 

constLinear

See if (data1 * C1) + C2 is the answer. In the form #(C2 C1) polynomialEval: data1


 

constMod

See if mod, (data1 \\ C) is the answer


 

constMult

See if (data1 * C) is the answer


 

constPlus

See if (data1 + C) is the answer


 

constUsingData1Value

See if (data1 <= C) or (data1 >= C) is the answer


  initialize top  
 

cleanInputs:

Find an remove common mistakes. Complain when ill formed.


 

copy:addArg:

Copy inputs and answers, add an additional data argument to the inputs. The same constant for every example


 

initialize

The methods we are allowed to use. (MethodFinder new initialize)


 

initialize2

The methods we are allowed to use. (MethodFinder new initialize)


 

initialize3

more selectors to consider


 

load:

Find a function that takes the data and gives the answers. Odd list entries are data for it, even ones are the answers. nil input means data and answers were supplied already.


 

noteDangerous

Remember the methods with really bad side effects.


 

organizationFiltered:

Return the organization of the class with all selectors defined in superclasses removed. (except those in Object)


 

test2:

look for bad association


 

test3

find the modification of the caracter table


 

testFromTuple:

verify that the methods allowed don't crash the system. Try N of each of the fundamental types. up to 4 of each kind.


 

testRandom

verify that the methods allowed don't crash the system. Pick 3 or 4 from a mixed list of the fundamental types.


 

verify

Test a bunch of examples


  search top  
 

exceptions

Handle some very slippery selectors.
asSymbol -- want to be able to produce it, but do not want to make every string submitted into a Symbol!


 

findMessage

Control the search.


 

insertConstants

see if one of several known expressions will do it. C is the constant we discover here.


 

search:

if Multi is true, collect all selectors that work.


 

searchForOne

Look for and return just one answer


 

simpleSearch

Run through first arg's class' selectors, looking for one that works.


 

testPerfect:

Try this selector! Return true if it answers every example perfectly. Take the args in the order they are. Do not permute them. Survive errors. later cache arg lists.


class methods
  as yet unclassified top  
 

methodFor:

Return a Squeak expression that computes these answers. (This method is called by the comment in the bottom pane of a MethodFinder. Do not delete this method.)