[textadept] Boolean Arguments

From: Robert <ro....at.web.de>
Date: Sun, 18 Dec 2011 21:31:44 +0100

Hi Mitchell,

there are quite a few cases in TA's API where some of the arguments
are boolean. If the function is not used very often this typically
requires looking up its meaning.
For a discussion of some real-world JavaScript API examples and
problems with boolean arguments see here:
http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html

One possibility would be to use tables as arguments, for example like

goto_view{1, relative = true} -- mixed named and positional arguments
or
goto_view{n = 1, relative = true}

Another option, a wrapper function
goto_view_relative(-1)

It is of course easy to look up the arguments because there is API
documentation available, still I think it would be better to have
something like
view:split("vertical")
or view:split_horizontal() and view:split_vertical()
than
view:split(true).

Possibly named functions are best, because they can be quickly used
through auto-completion.

Robert
Received on Sun 18 Dec 2011 - 15:31:44 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:26:35 EST