Dear Pharoers,
I'm just starting out with Pharo 6.1, and I'm trying to use code completion to interactively explore various objects and their messages. However, I'm having difficulties doing this efficiently - I think I must be missing something obvious, and I hope you can point me in the right direction. For instance, let's say I have the below in Playground: 'some text' asMorph and I would like to display the morph object as a window, but I don't know the exact message name, or whether such a message exists at all. If I type "Window", then the completion popup will show a long list of matching messages, but won't show their documentation or argument names, so it will be difficult to know exactly what these messages do. I can see that one can do "Do it and go" on an expression and then browse the available messages in Meta, but maybe there is simpler/faster way? How would an experienced Pharo user typically go about discovering the right messages in such situations? Best regards, Andrzej -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html |
Hi - I’m slightly ahead of you on that journey - but what I do is press shift-enter which gives you a great tool called spotter that lets you explore more interactively. In spotter if you also press cmd-p it will also preview method source too - so it’s close to what you are asking (and many methods have docs on their first line). However - selecting a method in spitter will also show you other senders of that method - some of those being test cases, which really give you insight into how to do most things. In fact this is a powerful element of Pharo that is often overlooked - as it’s written in itself, and all the source is there, there are excellent examples of how to do real things - even how the compiler and browsers work. I mention the latter, as it occurs to me that in the code completion list, it would be nice to press shift-enter on the method you are contemplating and be able to spot on it (or maybe even the whole autocompletion list) - I think this would actually be quite doable (armed with a bit of system knowledge of course). This was something I missed when I first came across Smalltalk - I was frustrated it didn’t do X (that my pascal environment did at the time ), not realising that it was simply 3 lines of code I could easily add to the environment myself (and nowhere near as complicated or painful as writing plugins for eclipse or IntelliJ). While at it - another nice trick, is to ctrl -shift click on any item in the environment and you get a little graphical halo appear - of which one icon is debug, which then let’s you inspect the code of that item (perhaps a button - which inevitably has an owner or a callback method you can then jump to and see the source of, and thus figure out how it works). It’s all very magical and dare I say fun... and this is why we love Smalltalk and Pharo , they are so malleable. Tim Sent by iPhone Sent from my iPhone > On 25 May 2018, at 02:12, andreo <[hidden email]> wrote: > > Dear Pharoers, > > I'm just starting out with Pharo 6.1, and I'm trying to use code completion > to interactively explore various objects and their messages. However, I'm > having difficulties doing this efficiently - I think I must be missing > something obvious, and I hope you can point me in the right direction. > > For instance, let's say I have the below in Playground: > > 'some text' asMorph > > and I would like to display the morph object as a window, but I don't know > the exact message name, or whether such a message exists at all. If I type > "Window", then the completion popup will show a long list of matching > messages, but won't show their documentation or argument names, so it will > be difficult to know exactly what these messages do. > I can see that one can do "Do it and go" on an expression and then browse > the available messages in Meta, but maybe there is simpler/faster way? > > How would an experienced Pharo user typically go about discovering the right > messages in such situations? > > Best regards, > Andrzej > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > |
In reply to this post by andreo
Hi Andrzej,
my way of doing it: Searching in the image what other guys are doing. Finder: asMorph and here you can find methods like #openAsMorph .. you can get a clue. or: ‘some text’ asMorph inspect .. than you get the object and you can search the class and from here the class the references. All my steps are based on code reading not code completion. Code completion I use more if I know what is should be and use the same method names as the other developers. Nic
|
Hi Tim and Nicole, Thanks for great tips. The click+keyModifier actions are extremely useful, and combined with breakpoints make for a great way of 'peeking under the hood' of the existing features. Also, I've just found a perfect piece of real code to do some learning and experimenting on - it will be the code completion itself! ;-) Andrzej On Fri, May 25, 2018 at 10:47 AM, Nicole de Graaf <[hidden email]> wrote:
|
That’s exactly the exploratory attitude we like to see...
I think the code completer is pluggable and can be selected in the settings (I think there are 2, and their history is probably in this list somewhere), so you can try your own too. Tim Sent from my iPhone
|
Try Cmd-q or Ctrl-q ( and right alt click on Windows). Spotter also has suffixes like #im #cl #sen to be put after a few keystrokes. Spotter: shift-enter (who knows). Phil On Sat, May 26, 2018, 22:16 Tim Mackinnon <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |