Here's a little change to get your #perform:withArguments: implemented.

| array lookupClosure method |
array := { 1 }.
lookupClosure := [].
lookupClosure := [:cls :selector |
    (cls == nil)
        ifTrue: [Warning signal: ('method lookup failure: ', selector)].
    cls methodDictionary
        at: selector
"        ifPresent: [:meth | Smalltalk tools browser openOnMethod: meth]"
        ifPresent: [:meth | meth]
        ifAbsent: [lookupClosure value: cls superclass value: selector]].
method := lookupClosure value: Array value: #at:put:.
method valueWithReceiver: array arguments: {1. 'Hello, world'}.
array


On 10/16/2016 9:32 AM, Ben Coman wrote:
On Sun, Oct 16, 2016 at 9:11 PM, Charlie Robbats
<charlie.robb...@gmail.com> wrote:
Here, Dmitry, try this code in playground...maybe helps you understand

| lookupClosure |
lookupClosure := [].
lookupClosure := [:cls :selector |
     (cls == nil)
         ifTrue: [Warning signal: ('selector lookup failure: ', selector)].
     (cls methodDictionary
         at: selector
         ifAbsent: [nil])
             ifNil: [lookupClosure value: cls superclass value: selector]
             ifNotNil: [:meth | Smalltalk tools browser openOnMethod: meth]].
lookupClosure value: Array value: #at:put:.
Nice example.  Slightly improved...

| lookupClosure |
lookupClosure := [].
lookupClosure := [:cls :selector |
     (cls == nil)
         ifTrue: [Warning signal: ('selector lookup failure: ', selector)].
     cls methodDictionary
         at: selector
         ifPresent: [:meth | Smalltalk tools browser openOnMethod: meth]
         ifAbsent: [lookupClosure value: cls superclass value: selector]].
lookupClosure value: Array value: #at:put:.

cheers -ben



Reply via email to