Weird Language Features

Donal K. Fellows fellowsd at cs.man.ac.uk
Mon Feb 19 05:49:03 EST 2001


Neil Madden wrote:
> Dave Cross wrote:
>> 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 put enough intelligence into the translator so that it could
>> handle certain strings differently depending on where they appeared in
>> the source code?
> 
> There are no reserved words in Tcl, so all keywords can be overwritten
> or renamed. Using the unknown command above, you can put as much
> intelligence as you want into interpreting a command. Although, this
> seems like a fairly dangerous thing to do, as any packages or extensions
> you used would have to know that the keywords had all been changed! But
> once again, you could allow the [unknown] handler to map commands onto
> their new names.

It'd be better to rewrite the [source] command as well, since then you
could apply the transformations at code-loading time as well, and if you
were doing something as static as supporting a second language for the
words of the program, then (as long as the literal strings used for the
two languages were distinct) you could easily use interpreter aliasing
instead.

Donal.
-- 
Donal K. Fellows    http://www.cs.man.ac.uk/~fellowsd/    fellowsd at cs.man.ac.uk
-- If somebody in a suit or a uniform can sit you down and have you believe
   every word he says, you've just surrendered your license to be a thinking
   human being and traded it in for a zombie suit. -- mhoye at prince.carleton.ca



More information about the Python-list mailing list