From: Mark Probert Date: 2003-01-07T02:28:44+09:00 Subject: Re: Compile time constant folding? Hi, Hal. At 12:56 AM 1/7/2003 +0900, Hal wrote: >Redefining things like Fixnum#+ to behave differently may be >bad coding style... but it is possible. As someone said, when >software prevents you from doing stupid things, it often >prevents you from doing very clever things as well. I think I now understand where my thinking is going off. We are talking about "constant folding". When I see the expressions: a = 5 b = 3 c = a + b Then I am seeing the operators (assignment and addition) as constant as well as values (base 10). So, I can confidently say that the above reduces to c = 8 However, given that I (the coder) can dynamically change the operators, there is no way that the compiler can "guess" that this is true. So as Dan suggested, I may later redefine "+" as string cat and mean c = "53" -laugh- And this seems wrong to me. If I had meant that, why didn't I write that in the first place? Certainly as a maintainer of code, I would want it to be very clear what is happening. After all, these values are meant to be constants ... Ahhh ... here comes Mr Ockham and his razor ;-) -mark.