Weird Language Features
Jeffrey Hobbs
JeffH at ActiveState.com
Mon Feb 19 12:42:47 EST 2001
Dave Cross wrote:
...
> 1/ The programmer calls a function that doesn't actually exist within
> the application (or libraries). Is the a feature whereby the
> programmer can create a "catch-all" function which is called in cases
> like these? Can this function examine the list of existing functions
> and call the most appropriate one? Or create a new function on the fly
> and install it into the application?
For Tcl, yes this is a standard feature, set in the 'unknown' procedure,
which can be redefined by the user. The default behavior is to use it
for lazy-loading of new procedures. It has also been used to handle
completely new syntax structures in Tcl.
> 2/ Can ou filter the input source code before compilation (or
> interpretation) in some way so that language keywords could be changed
> for other strings? Imagine you wanted to allow someone to program your
> language of choice in, say, French. How would you go about translating
> French keywords into ones that the compiler (or interpreter) could
> understand. What if the translation wasn't one-to-one or fixed? Could
You could build this with any language using message catalogs or the
like. It's very easy with interpreted languages, and Tcl for one has
the facilities (helper modules) built in.
--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
More information about the Python-list
mailing list