develooper Front page | perl.perl6.internals | Postings from September 2005

Tcl - compiling expressions

Thread Next
Will Coleda
September 29, 2005 09:00
Tcl - compiling expressions
Message ID:
Tcl's [expr] command now compiles expressions to PIR (before, it  
would create an AST that it would then interpret when you wanted the  
value.). Note: the language itself is still interpreted, this is only  
one command in the language.

E.g: given a command like

while {$a < 10} {incr $a}

Originally, the while would parse the $a < 10 expression once, then  
interpret it (walk through the AST and generate a value) each time.  
Now, it compiles the expression to PIR once:

.pragma n_operators 1
.sub blah @ANON
.local pmc read
read=find_global "_Tcl", "__read"
.local pmc number
number=find_global "_Tcl", "__number"
$P0 = read("a")
$P0 = number($P0)
$P1 = new .TclInt
$I2 = islt $P0, $P1
$P2 = new .TclInt
$P2= $I2
.return ($P2)

and then just invokes it when it wants the current value.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About