On 8 February 2018 at 16:22, Stephane Ducasse <stepharo.self@gmail.com> wrote:
Hi denis
- I would like to be able to define a method even in the class pane and that the system detects it automatically.
It would be nice to do it from anywhere including Playground with something like... Classname >> #methodname >> [ method source here ] So I just tired a quick experiment... Object subclass: #SomeClass instanceVariableNames: '' classVariableNames: '' package: 'MethodBuilderExperiment' On SomeClass defined method... existingMethod ^1 On CompiledMethod defined method... >> blockClosure | newSource | newSource := self methodNode selector, String crlf, blockClosure sourceNode newSource allButFirst allButLast. self methodClass compile: newSource Now each of the following lines can be evaluated... SomeClass existingMethod "==> 1" SomeClass >> #existingMethod >> [ ^42]. SomeClass existingMethod "==> 42" And another experiment... Object subclass: #MethodBuilder instanceVariableNames: 'methodClass methodSelector' classVariableNames: '' package: 'MethodBuilderExperiment' On MethodBuilder defined method... class: aClass selector: aSelector methodClass := aClass. methodSelector := aSelector. On MethodBuilder defined method... >> blockClosure |newSource| newSource := methodSelector, String crlf, blockClosure sourceNode newSource allButFirst allButLast. methodClass compile: newSource On Behaviour re-defined method... compiledMethodAt: selector ^ self methodDict at: selector ifAbsent: [ MethodBuilder new class: self selector: selector ] Now each of the following lines can be evaluated... Someclass noMethod "==> error... Instance of SomeClass class did not understand #noMethod" SomeClass >> #noMethod >> [ ^42 ]. Someclass noMethod "==> 42" cheers -ben
- Then we are starting to reverse engineering the ecompletion system and I'm learning it. I would like to know if Calypso can communicate with ecompletion the fact that we are defining a method. Then I have to check how the system can know that we are typing method argument when defining the signature but I think that this is not related to calypso.
Stef