Weird Language Features

sss sss at ed.com
Wed Feb 21 12:59:12 CET 2001


Ruby

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?
>

"method_missing(...)" does it, either per class or when  overwriting
Object>>method_missing(...) globally


>
> 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?

'alias' allows you to create an alias for any method of any class.
Language keywords such as class, module, while , etc. cannot be aliased
though.

Clemens




More information about the Python-list mailing list