RE: constant -> constant
- To: mathgroup at smc.vnet.net
- Subject: [mg41961] RE: [mg41945] constant -> constant
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Wed, 11 Jun 2003 13:17:53 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: carlos at colorado.edu [mailto:carlos at colorado.edu] To: mathgroup at smc.vnet.net >Sent: Wednesday, June 11, 2003 9:50 AM >To: mathgroup at smc.vnet.net >Subject: [mg41961] [mg41945] constant -> constant > > >I traced a bug in a large program to an unexpected >substitution. This gives the idea: > >a=b=0; Print [a/.b->1]; > >1 > >Is this correct behavior and, is there a way to guard >against this happening? > Carlos, see In[7]:= a /. b -> 1 // Trace Out[7]= {{a, 0}, {{b, 0}, 0 -> 1, 0 -> 1}, 0 /. 0 -> 1, 1} That's what you ordered. First a evaluates to 0 Then b to 0 Then 1 to 1, giving 0 /. 0 -> 1 that is: take 0 and replace 0 by 1, result 1. -- Hartmut