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

Tcl - compiling expressions

Thread Next
From:
Will Coleda
Date:
September 29, 2005 09:00
Subject:
Tcl - compiling expressions
Message ID:
0DA6C74F-7A5B-4274-8B7C-0109EFC5CC75@coleda.com
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
$P1=10
$I2 = islt $P0, $P1
$P2 = new .TclInt
$P2= $I2
.return ($P2)
.end

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



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About