[squeak-dev] Why doesn't ECompletion / OCompletion use a Trie?

Levente Uzonyi leves at elte.hu
Wed Jun 15 10:23:29 UTC 2011


On Tue, 14 Jun 2011, Juan Vuletich wrote:

> Hi Folks,
>
> I've been playing a bit with ECompletion / OCompletion on Cuis (thanks, 
> Levente!). What surprises me is the use of a single level Dictionary with 2 
> character prefixes as the data structure to hold the string dictionary. Does 
> anybody know why a Trie ( http://en.wikipedia.org/wiki/Trie ) wasn't used?

OCompletion suggests the recently used methods, therefore the length of 
the list for each prefix is limited to 40 by default. So looking up 
selectors beginning with a two letter prefix is fast enough (I increased 
it to 400 in my image and it's still fast enough). 40 is not always 
sufficient, sometimes the method you're looking for is not in the list of 
the three recently used methods, but it works for most cases.
With a trie you'd have to sort the words matching the prefix by access 
time for every lookup which may be less efficient, especially for small 
prefixes. A trie would also have to hold all possible selectors, while the 
lists limited to 40 avoid this.

Btw, I'm thinking about integrating code completion into Squeak itself. 
The idea is to add hooks to the system for code completion and provide an 
implementation for common things, like menus, key bindings, etc. There 
would also be a simple symbol table based completion tool integrated by 
default, like Cmd+Q, but with menus, like in Pharo. Then stripped down 
versions of E/OCompletion could be loaded as a replacement. I'm also 
thinking about implementing a mix of ECompletion and OCompletion which 
would show the recently used selectors first like OCompletion, but 
filters/sorts the suggestions based on type information like ECompletion.


Levente

>
> Thanks,
> Juan Vuletich
>
>



More information about the Squeak-dev mailing list