[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Source filters

On Wed, 21 May 2003, Michael Vanier wrote:

> Much as I hate to compliment perl ;-) ;-), that's pretty effing amazing.  I
> wonder what the original motivation was for this feature.  I can't imagine
> there was that much call for latin (or pig-latin, or esperanto...).  In
> some ways this takes the macro concept to its logical extreme (although I
> doubt it's as easy to manipulate code as it is in lisp/scheme macros).
> Do any other languages have this feature?

I've always been a big fan of the #compilerClass method in Smalltalk.
This is a class side method that returns the compiler implementation with
which a class would like its instance side methods to be compiled.
Object implements this to return the standard Compiler class,
but other classes are free to override it.  The source code for methods of
these classes may look completely different from other Smalltalk code, but
the IDE won't blink an eye.

Since people are probably more familiar with Java than with Smalltalk,
this is roughly equivalent to being able to do:

class MyClass
  static Class compilerClass() { return SchemeCompiler.class; }

  public int addTwoNumbers(int x, int y) {
    (+ x y)

class SchemeCompiler implements Compiler