[IDEA] 'buildNewMethods' Preference

Bob Arning arning at charm.net
Thu Nov 25 00:18:52 UTC 1999


On Wed, 24 Nov 1999 15:34:14 -0800 (PST) Ali Chamas <alichamas at yahoo.com> wrote:
> When Squeak accepts a freshly coded method, and it
>comes across a method name which you've typed which is
>undefined, it throws up a menu with some suggestions
>for an existing method, or a cancel. It would be great
>to have an extra key in the Preferences which was
>called 'buildNewMethods' (or something), and if set to
>true, would mean that any undefined methods you type
>in as you're coding would be auto-built for you upon
>accepting the new code. Even if the preference was set
>to false, it could still be an option of the methods
>menu which pops up after accepting a new method.
>
>Consider coding away, and you wrote:
>
>| foo |
>foo _ self aMethodIJustThoughtOf.
>
>When you accept this method, #aMethodIJustThoughtOf
>would be created (with the usual "^ self" minimal) in
>the current methods category (or maybe a new category
>called 'Other'), and then a) you know that the code
>doesn't break, b) you're not interupted by a
>correction menu for something which was quite
>intentional.

Hmmm... 
- If you had the preference set to true, would the method *always* be created? What if you actually misspelled the selector?
- Where would the method get created? Even "self" in your example could be construed to mean this class OR one of its superclasses. What if the receiver is not explicitly "self"?
- Why do you assume a method returning self would not break? Suppose I wrote:

	self dateOfBirth year

and, since there was no method in this class named #dateOfBirth, one was created automatically. Would "self" (the default value returned) understand #year? Maybe, maybe not. Would it be right? Probably not.

My personal course of action in such cases is:
- If I misspelled the method, I fix it.
- If I had the selector the way I wanted it, I select the first item in the menu that pops up and the compiler accepts my word that all is OK. I then copy the selector from the browser I was typing in, spawn a new browser and create the method wherever it needs to be.

Cheers,
Bob





More information about the Squeak-dev mailing list