From: Dan Sugalski Date: 2003-01-06T10:08:29+09:00 Subject: Re: Compile time constant folding? At 9:19 AM +0900 1/6/03, Mark Probert wrote: >Hi. > >Dan Sugalski wrote in comp.lang.ruby: >> >> Is it valid to do compile-time constant folding as an optimization? >> > >IMO, the POLS wouldn't be breeched if this were to happen. >Unless the overloaded operator does something completely >strange (eg redefine "+" as "*"). I guess that typing may >also be an issue. I can see it going either way--the interpreter could do what it's doing on purpose, or because the optimization just never was done. (Or that it wasn't ever really thought about) It's not like this is expensive in the simple case, but when you do something like: (1 / sin(2.3)) * log(4) in a loop, well, that can add up pretty quickly. -- Dan --------------------------------------"it's like this"------------------- Dan Sugalski even samurai dan@sidhe.org have teddy bears and even teddy bears get drunk