For Programmers: Free Programming Magazines  


Home > Archive > Tcl > June 2006 > Re: Switch and Regexp compiler optimizations (was Re: Solved: ::errorStack









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Switch and Regexp compiler optimizations (was Re: Solved: ::errorStack
Donal K. Fellows

2006-06-26, 7:07 pm

Alex wrote:
> Sounds like redundancy / behavior duplication to me...
> Any hope of factoring out ?
> In a language with smart macros (a la Lisp), I'd define [switch] as a
> macro emitting a series of
> ... elseif {[regexp {...} $__value]} { } ...
> then all the regexp optimization/degenerate cases would, as usual, be
> done by the normal compilation of [regexp].


Apart from one or two very subtle issues relating to variables (i.e.
[info locals] and [trace]) you're right. But just because it could be
done doesn't mean that it is done. And the chained [if] solution
precludes the jump table stuff unless you do a lot of (usually useless)
optimization work. To cap it all, writing a proper optimizer for the Tcl
bytecode system is probably very difficult at the moment (some of the
design decisions taken back in Tcl 8.0 were sub-optimal).

It's all rather messy.

Donal.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com