[Cuis-dev] finding methods by example
Boris Shingarov
shingarov at labware.com
Mon Jan 27 11:15:56 PST 2025
This is very intriguing, and I am suspected may be related to an issue
I've been chasing for a while.
So I loaded the latest commit (e7b89a6) of MethodFinder into today's
fresh Cuis, and stepped through the code in the Debugger, but how do
I reproduce your surprising result? There is no #methodsByExample:.
IIUC we are just looking for methods that match on *all* members of
the given collection? So with just one element, this would be
equivalent to
MethodFinder methodsFor: #(1 2).
Where does the "double" Block enter this picture? I don't think there
is a method #double in Cuis, is there?
On Sun, Jan 05, 2025 at 05:26:20PM -0600, Mark Volkmann via Cuis-dev wrote:
> This revealed something that surprised me. I expected this to tell me that
> an answer is the collect: method.
>
> double := [:x | x * 2].
> Finder methodsByExample: { #(1 2 3). double. #(2 4 6) }.
>
> But I didn't know it would tell me that these methods also return the same
> result:
>
> ifNotEmpty:
> ifNotNil:
> replace:
> stonProcessSubObjects:
>
> On Sun, Jan 5, 2025 at 2:50 PM Mark Volkmann <r.mark.volkmann at gmail.com>
> wrote:
>
> > I understand that the Squeak development environment provides a way to
> > find methods by example. As a fun exercise I wanted to see if I could
> > implement that in Cuis, minus the GUI. I created a Finder class with a
> > single class method methodsByExample that does this. It's amazing how
> > fast it is!
> >
> > For example, evaluating the following in a Workspace:
> >
> > Finder methodsByExample: #(#(1 2 3 4) 2.5)
> >
> > prints the following in the Transcript:
> >
> > The following methods on #(1 2 3 4) with no arguments return 2.5:
> > - average
> > - mean
> >
> > The hardest part was discovering all the methods that have side effects
> > which should not be attempted. Perhaps I haven't found all of them yet.
> >
> > My code is in a package at
> > https://github.com/mvolkmann/Cuis-Smalltalk-FindByExample. There are more
> > examples in the README. I welcome feedback on ways this can be improved.
> >
> > --
> > R. Mark Volkmann
> > Object Computing, Inc.
> >
>
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
More information about the Cuis-dev
mailing list