0

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?

  • Not coherent enough for an answer, but you type the first few characters of the function name and trigger a hotkey for a list of functions that match the prefix you typed (and often also the expected arguments) – Bart van Ingen Schenau Mar 8 '14 at 19:44
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:

  1. 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.

  2. Dumb text completition can complete words which occur in the same file or project. So if there is a method foobar() somewhere, typing foo could be completed to foobar. Unfortunately, a variable foobaz would be suggested as well.

  3. Any form of more advanced completition. Let's assume we want to call frobnicate on a Foo instance, and the syntax is method(instance, arguments...). Then typing fro might suggest

    frobnicate(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.

  • I guess I was thinking of a use case where you know you want a function that operates on a Foo and an int, but you don't remember the name frobnicate. But yes, suggestion #1 would come in handy there. – echristopherson Mar 9 '14 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.