Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Block and Module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15157] Re: Block and Module
  • From: "A.ODA" <a-oda at muj.biglobe.ne.jp>
  • Date: Wed, 16 Dec 1998 03:11:28 -0500
  • Organization: BIGLOBE dial-up user
  • References: <74tce8$4vs@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

David Epstein wrote in message <74tce8$4vs at smc.vnet.net>...
>Could someone explain what the difference is between Block and Module? A
>couple of easy examples would help, rather than a long theoretical
>explanation.
>
>David Epstein

>

Try these two examples.

ex. 1
Module[{PlotRange},
 Plot[Sin[x],{x,0,Pi},PlotRange->{0,2}]];

ex.2
Block[{PlotRange},
 Plot[Sin[x],{x,0,Pi},PlotRange->{0,2}]];

The ex.1 will stop by "Unknown option" but ex.2 will work as you
expected.

"Module" assigns new address for local variable, so the actual name of
the variable in ex.1 is PlotRange$1 or $number. However, "Block" simply
save  and retrieve value of variable in the first argument. Usually,
Module and Block work same, unless you use some global variables. Most
useful technique of Block is temporal change for some global variables
which affects system defaults like RecursionLimits.

A.ODA <a-oda at muj.biglobe.ne.jp>
Kawasaki, JAPAN




  • Prev by Date: Re: Q: Linearization
  • Next by Date: Re: Global max for a nonlinear function
  • Previous by thread: Re: Block and Module
  • Next by thread: Output Leading up To Answer?