Re: repo to work on python scripting support

Jim Blandy
2008-03-25T21:41:58Z

On Tue, Mar 25, 2008 at 12:31 PM, Paul Koning <Paul_Koning@dell.com> wrote:
> The notion of asking for a particular type is a bit foreign to Python;
> arguments have no fixed type.

It's not really about type. For example, Emacs has about a dozen
interactive spec code letters that compute string arguments for the
function. Some are filenames, some are buffer names, some are bits of
text... It's about how to prompt for the arguments. Or, in the case
of $() functions in GDB, how to parse the arguments.

> Another possibility is to pass strings but then have standard
> conversion routines (things callable by Python and supplied by gdb).
> For example parse_and_eval_address. And the target functions. And so
> on.
>
> def walklist (head):
> addr = parse_and_eval_address (head)
> while addr:
> print "list item at", addr
> addr = target_read_memory (addr, 4)

Using "None" this way means that the function's arguments are (say)
"address, or None if I should prompt interactively."

The nice thing about interactive specs is that the function itself has
a single contract to follow: each of its arguments always means the
same thing, whether the function is invoked from code or interactively
by the user.

You may also get interactive prompting by accident, if you pass the
wrong arguments to the function.