In method call syntax in many object-oriented languages, the receiver object goes to the left of the method name, e.g. someObject.someMethod()
. This comes in handy when using an IDE with code completion/code assist/Intellisense; when the user types a method call expression, the receiver has already been typed, so the IDE can narrow down its method choices to apply to that receiver (at least in statically-typed languages).
What I’m wondering is, what is the user interface for method/function completion like in languages where the method or function name goes before its receiver and/or arguments, e.g. Lisp or C? Does the user have to trigger a hotkey, to which the IDE responds by asking for the receiver and/or arguments, and then once the value is typed in the IDE pops up a list of methods or functions that are applicable to that list?
1
(Short answer – it depends: there are a gazillion different IDEs and editors which might all handle such cases slightly differently, so there is no single user interface which everyone uses)
The problem is much larger than just languages where the method comes before the invocant. What horror must it be to program in languages that don’t even support OOP, or which are dynamically typed so that we have no idea what methods could be called on the object inside some variable!
There are a number of ways out of this conundrum:
-
Just remember what methods can be called on what type. And if we aren’t sure, we can always read the documentation. You would be surprised how well this works.
-
Dumb text completition can complete words which occur in the same file or project. So if there is a
method foobar()
somewhere, typingfoo
could be completed tofoobar
. Unfortunately, a variablefoobaz
would be suggested as well. -
Any form of more advanced completition. Let’s assume we want to call
frobnicate
on aFoo
instance, and the syntax ismethod(instance, arguments...)
. Then typingfro
might suggestfrobnicate(Foo foo, int x) frobnicate(Bar bar, int x, int y) frodo
You can be quite productive without intellisense-like autocompletition, although it’s a very nice feature to have.
My primary language happens to be dynamically typed and defies any static analysis (metaprogramming is too nice to give up), so suggesting available methods for some object is absolutely impossible. But the problem is smaller than it seems: Not all my code is object oriented, quite often procedural or functional code is a better fit. I also survive by reading the docs of the libraries I use. The dumb text completition which my editor offers is a general speedup – it’s more work than getting only sensible suggestions, but it’s still a lot faster than typing out everything. The way I’ve set up my editor, no shortcut is required to trigger suggestions, only a prefix of some minimal length.
1