Updated 2014-01-20 13:07:28 by RLE

I often run into syntactic prejudice when I am writing software to spec. This often seems to preclude using Tcl, and precluding Tcl, of course, tends to bloat the amount of work and the time and money needed to accomplish it. Eventually, however, I came up with the "run" command - it's a replacement for "source" but it does some extensive preprocessing before running the code, allowing some really radical language changes without any run-time overhead.

See run for the code...

Now, suppose we wish to add some syntactic sugar to expr, and to have an input language looking like Oberon or Modula. We code this:
 source run.tcl

(see run for the compute proc, mentioned next).

"compute" is a macro that handles the translation of "expr", and "xlate" is a simple textual substitution table. Now we can take the file "foo.tcl":
 # basic tcl syntax is still there:
 set x 1

 # So is new modula-style
 IF x <> 1 THEN
   puts "x is NOT 1"
 ELSE
   puts "x IS 1"
 END

and run it from a tcl script:
 run foo.tcl xlate

and what is actually sourced is:
 set x 1

 if { $x != 1 } {
   puts "x is NOT 1"
 } else {
   puts "x IS 1"
 }

sdw - Another take on this concept is TAO, essentially implementing OOP techniques using a pre-processor fed by an sql database.

Sarnold - See also xsource for source preprocessing ideas.

Larry Smith: Why is this page duplicating run and doing so without crediting me?

CMcC it appears, by comparing history of modification, that the person creating run also created this page, and that this page was created first. Both were created nearly 5 years ago.