Re: Euphoria Code Optimiser
- Posted by Robert Craig <rds at EMAIL.MSN.COM> Mar 21, 1998
- 872 views
Daniel writes: > By the way Rob (if you are still reading) > are calculations with constants in > optimised at compile-time ? > eg > constant my_num=396 > sequence bar > for a=1 to very_big do > bar={1,2,3}/my_num > grill(bar) > end for > compiles > <snip> > bar={ 0.002525252525253, 0.005050505050505, > 0.007575757575758} > <end snip> It would be easy to add "constant folding" into Euphoria's optimizer, but it hasn't been done yet because I rarely see a time-critical section of code where a programmer repeatedly calculates with constant values. People are smart enough to perform the calculation once and assign the result to a variable or constant, or at least move the calculation out of an inner loop. I've been tempted many times in the past to add this, but there just don't seem to be enough cases in practice where it actually matters. Before adding any optimization to Euphoria, I like to scan through my directory of user contributions to see how often the optimization would actually pay off. That way I avoid making the compiler more complicated without any real benefit. Your other idea of making a pre-processor that converts inefficient Euphoria code into efficient Euphoria code sounds interesting. Regards, Rob Craig Rapid Deployment Software P.S. The 2.0 Official Release will be out in less than a week. Please send any last-minute bug reports to: rds at msn.com Thanks.