Hi denis
- I would like to be able to define a method even in the class pane and that the system detects it automatically. - 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 |
On 8 February 2018 at 16:22, Stephane Ducasse <[hidden email]> 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 > |
On 9 February 2018 at 00:45, Ben Coman <[hidden email]> wrote: > On 8 February 2018 at 16:22, Stephane Ducasse <[hidden email]> 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" That should have been. SomeClass new existingMethod "==> 1" SomeClass >> #existingMethod >> [ ^42]. SomeClass new 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" And should have been... Someclass new noMethod "==> error... Instance of SomeClass class did not understand #noMethod" SomeClass >> #noMethod >> [ ^42 ]. Someclass new noMethod "==> 42" I see that is a bit problematic for keyword messages, but with a tweak... On MethodBuilder defined... >> blockClosure |newSource| methodSelector isArray ifFalse: [ newSource := methodSelector ] ifTrue: [ newSource := ''. methodSelector do: [ :token | newSource := newSource , token asString, ' ' ] ]. newSource := newSource, String crlf, blockClosure sourceNode newSource allButFirst allButLast. methodClass compile: newSource now the following can be evaluated... SomeClass >>#(echo: anObject) >> [ ^anObject ]. SomeClass new echo: 'doyoulike'. "==> doyoulike" Another form to define a method might be... SomeClass >> [ echo: anObject ^anObject ] I think that looks better, but would require a loosening of block syntax. >> - 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 >> |
Hi ben
This is not what I asked for :). In nautilus you do not have to switch mode to define a method. Now about your proposal. I would like to be able the type tonel method definition SomeClass >> echo: anObject [ ^ 42 ] Tonel represents what I want for methods. This way students could just type nearly as in the books and I would change the book to reflect this. And people can decide either to type all the time the class or now. Stef On Thu, Feb 8, 2018 at 6:28 PM, Ben Coman <[hidden email]> wrote: > > > On 9 February 2018 at 00:45, Ben Coman <[hidden email]> wrote: >> On 8 February 2018 at 16:22, Stephane Ducasse <[hidden email]> >> 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" > > That should have been. > > SomeClass new existingMethod "==> 1" > SomeClass >> #existingMethod >> [ ^42]. > SomeClass new 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" > > And should have been... > Someclass new noMethod "==> error... Instance of SomeClass class did not > understand #noMethod" > SomeClass >> #noMethod >> [ ^42 ]. > Someclass new noMethod "==> 42" > > > I see that is a bit problematic for keyword messages, but with a tweak... > > On MethodBuilder defined... > >> blockClosure > |newSource| > methodSelector isArray > ifFalse: [ newSource := methodSelector ] > ifTrue: [ > newSource := ''. > methodSelector do: [ :token | newSource := newSource , token asString, ' ' ] > ]. > newSource := newSource, String crlf, > blockClosure sourceNode newSource allButFirst allButLast. > methodClass compile: newSource > > > now the following can be evaluated... > > SomeClass >>#(echo: anObject) >> [ ^anObject ]. > SomeClass new echo: 'doyoulike'. "==> doyoulike" > > > Another form to define a method might be... > SomeClass >> [ echo: anObject > ^anObject ] > > I think that looks better, but would require a loosening of block syntax. > > 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 >>> > |
Then you might have used kind of named block params like MyClass >> [foo: aFoo bar: aBar | self foo: aFoo; bar: aBar] Le 8 févr. 2018 20:11, "Stephane Ducasse" <[hidden email]> a écrit : Hi ben |
In reply to this post by Stephane Ducasse-3
Hi Stef. There is no problem to add extra logic in class editor. Give me the code and I will add it. But I guess you saw how class definition is evaluated in the browser. It is big mess with many "if statements" and manual parsing of definition parts. I wish we will clean it with proper class compiler. 2018-02-08 11:22 GMT+03:00 Stephane Ducasse <[hidden email]>: Hi denis |
Yes denis this is something that we started to clean and we got distracted.
On Fri, Feb 9, 2018 at 8:59 AM, Denis Kudriashov <[hidden email]> wrote: > Hi Stef. > > There is no problem to add extra logic in class editor. Give me the code and > I will add it. > > But I guess you saw how class definition is evaluated in the browser. It is > big mess with many "if statements" and manual parsing of definition parts. > I wish we will clean it with proper class compiler. > > 2018-02-08 11:22 GMT+03:00 Stephane Ducasse <[hidden email]>: >> >> Hi denis >> >> - I would like to be able to define a method even in the class pane >> and that the system detects it automatically. >> >> - 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 >> > |
Denis I thought that we can see class comments and class definition/
method definition. This is super annoying not to be able to see the class comments especially when we have large screens. Did I missed something? Stef On Fri, Feb 9, 2018 at 1:33 PM, Stephane Ducasse <[hidden email]> wrote: > Yes denis this is something that we started to clean and we got distracted. > > On Fri, Feb 9, 2018 at 8:59 AM, Denis Kudriashov <[hidden email]> wrote: >> Hi Stef. >> >> There is no problem to add extra logic in class editor. Give me the code and >> I will add it. >> >> But I guess you saw how class definition is evaluated in the browser. It is >> big mess with many "if statements" and manual parsing of definition parts. >> I wish we will clean it with proper class compiler. >> >> 2018-02-08 11:22 GMT+03:00 Stephane Ducasse <[hidden email]>: >>> >>> Hi denis >>> >>> - I would like to be able to define a method even in the class pane >>> and that the system detects it automatically. >>> >>> - 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 >>> >> |
Free forum by Nabble | Edit this page |