Re: More /.{I->-1} craziness

*To*: mathgroup at smc.vnet.net*Subject*: [mg106122] Re: More /.{I->-1} craziness*From*: Noqsi <jpd at noqsi.com>*Date*: Sat, 2 Jan 2010 05:04:25 -0500 (EST)*References*: <200912300915.EAA17299@smc.vnet.net> <hhhmn8$o9t$1@smc.vnet.net>

On Jan 1, 3:39 am, Richard Fateman <fate... at cs.berkeley.edu> wrote: > Leonid Shifrin wrote: > > ... > > > > > I think that there are not many more objects in Mathematica which are a= s > > tricky as <I> or Infinity in terms of pattern-matching. > > I agree. > That's why it can be fixed. > > Here's a beginning of a short list for the "we're not just talking > syntactic replacement-- version of substitution": > > If the user says -i --> i, then do Complex[a_,-b_] -> Complex[= a,b]. > If the user says x^2 --> y, then do x^(-2)-> 1/y also. > > I assume this list can be enlarged somewhat, and could even be left > open-ended by user option of some sort. [e.g. should x^2--> y also > change x^3 to x*y? or to y^(3/2) or ....] No! The language should not attempt to outsmart the user. What you're proposing would be the nastiest sort of bug, changing simple, predictable behavior into something that would play out in incomprehensible ways. Syntactic replacement is very, very useful and should not be polluted by attempts to read the user's mind. The principle here has always been "You want to see what a rule will really do? Look at FullForm." Perhaps the documentation should highlight this better, but this behavior is NOT A BUG.