create new statement?
Tim Peters
tim.one at home.com
Fri Mar 2 14:18:20 EST 2001
[Bruce Edge]
> Can you add a new statement to python?
Yes, but you probably can't <wink>. That is, the set of statements is fixed,
and to add a new statement you would need to change the grammar of the
language, rebuild the parse tables, and alter the compiler to generate
appropriate code for it.
> ...
> I want to add my own command to the interp, but not have to use object
> calling syntax
> eg:
> create obj opt
> not
> create(obj, opt)
>
> How do I define new statements, or, a way of calling functions using the
> former syntax?
You don't, in Python. "It's a feature" that everyone's code looks the same
here. You can do that in Perl, though. Without changing the language
implementation, the closest you could get in Python would be to write a
source-to-source (or source-to-bytecode) translator of your own, that output
legitimate Python source (or bytecode).
python's-syntax-is-neither-extensible-nor-overridable-ly y'rs - tim
More information about the Python-list
mailing list