From: Daniel Carrera Date: 2003-02-27T12:31:09+09:00 Subject: Re: Ruby Compile-time optimization > > I realize that the fact that Ruby is a more dynamic language makes > > optimization more difficult, but I really think that we should look into > > it. > > If you poke around in the mailing lists, you'll find it has been brought > up before. In short, Fixnum#+ may be redefined at any time, so > constant folding won't work. Yes, I realize that. That's the kind of problem that I referred to when I said that Ruby was dynamic. I think that we should try to find a way to optimize Ruby code. For instance, here are two ideas for implementing constant folding: 1) Create a "Constant" class whose "+" operator cannot be overloaded and whose value cannot be changed. 2) Give Ruby a '-O' option that does constant folding and raises an error if you either change the value of a constant or overload Fixnum#+. I'm not saying that these are *good* ideas. What I'm saying is that we might be able to come up with something. Idea (2) is not too unreasonable. -- Daniel Carrera Graduate Teaching Assistant. Math Dept. University of Maryland. (301) 405-5137