scripting language newbie - compatibility

Paul Duffin pduffin at hursley.ibm.com
Tue Aug 8 20:19:17 EDT 2000


Martijn Faassen wrote:
> 
> Paul Duffin <pduffin at hursley.ibm.com> wrote:
> [snip]
> > Actually you can generate byte compiled versions of Tcl which you can
> > distribute but you need to use a commercial package called TclPro to
> > do that. It is certainly not as easy as Python but pre byte compiling Tcl
> > code is not as useful as pre compiled Python code because of Tcl's dynamic
> > nature.
> 
> How would Tcl be more dynamic than Python? (you seem to be
> implying this) 

AFAIK it is. Tcl does not have any special flow control statements, instead 
it provides flow control commands. These commands are the same as any other
command and therefore can be redefined. AFAIK Python does not allow "if" to
be redefined whereas Tcl does.

> And how does a language's dynamic nature stop it from
> being (usefully) byte-compiled?
> 

Byte compilation is done on the fly when data is executed as code and 
depends on the command not having been redefined. The byte compiled code
is invalid as soon as any of the commands that it uses and which can be 
byte compiled are redefined. Actually Tcl invalidates all byte compiled
code as soon as a command which can be byte compiled is redefined.

In order for byte compiled code which has been saved into a file to behave
properly it would need the complete source code so that it could be 
recompiled if a byte compiled command had been redefined. 

Tcl does not actually invalidate byte compiled code which has been loaded
from a file as that would eliminate most of the benefits of providing
pre byte compiled code in the first place, namely speed and code hiding.

> Perhaps you mean Tcl is more dynamic on the syntactic level somehow?
> 

It depends what you view as the syntax. 

If you use syntax in the sense of Python, C, Pascal, ..., i.e. including 
flow control statements, reserved words etc. then Tcl's syntax is very 
dynamic as you can create new flow control statements and redefine others.

If you use syntax in the Tcl/Lisp sense then its syntax is very rigid and 
very simple.




More information about the Python-list mailing list