Re: Dynamic scoping
- To: mathgroup at smc.vnet.net
 - Subject: [mg129652] Re: Dynamic scoping
 - From: "Rolf.Mertig at gmail.com" <Rolf.Mertig at gmail.com>
 - Date: Sun, 3 Feb 2013 02:44:43 -0500 (EST)
 - Delivered-to: l-mathgroup@mail-archive0.wolfram.com
 - Delivered-to: l-mathgroup@wolfram.com
 - Delivered-to: mathgroup-newout@smc.vnet.net
 - Delivered-to: mathgroup-newsend@smc.vnet.net
 - References: <keiatl$qq3$1@smc.vnet.net>
 
Am Samstag, 2. Februar 2013 07:15:17 UTC+1 schrieb Daniel Huber:
> Block is supposed to be a dynamic scoping construct. Therefore, in the following, "Print" should be an undefined function. But consider:
> 
> 
> 
> Block[{Plus},
> 
>  t = ToString[Plus[1, 2]];
> 
>  Print[t];
> 
>  ]
> 
> 
> 
> The output of this is: "3" and not "Plus[1,2]" as it would be if "Print" has no defined meaning.
> 
> cheers, Daniel
Block[{Plus = "Plus"}, t = ToString[Plus[1, 2]];
 Print[t];]
will do what you want