Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6119467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:33:23+00:00 2026-05-23T15:33:23+00:00

Leonid wrote in chapter iv of his book : "… Module, Block and With.

  • 0

Leonid wrote in chapter iv of his book : "… Module, Block and With. These constructs are explained in detail in Mathematica Book and Mathematica Help, so I will say just a few words about them here. …"

From what I have read ( been able to find ) I am still in the dark. For packaged functions I ( simply ) use Module, because it works and I know the construct. It may not be the best choice though. It is not entirely clear to me ( from the documentation ) when, where or why to use With ( or Block ).

Question. Is there a rule of thumb / guideline on when to use Module, With or Block ( for functions in packages )? Are there limitations compared to Module? The docs say that With is faster. I want to be able to defend my =choice= for Module ( or another construct ).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:33:24+00:00Added an answer on May 23, 2026 at 3:33 pm

    A more practical difference between Block and Module can be seen here:

    Module[{x}, x]
    Block[{x}, x]
    (*
    -> x$1979
       x
    *)
    

    So if you wish to return eg x, you can use Block. For instance,

    Plot[D[Sin[x], x], {x, 0, 10}]
    

    does not work; to make it work, one could use

    Plot[Block[{x}, D[Sin[x], x]], {x, 0, 10}]
    

    (of course this is not ideal, it is simply an example).

    Another use is something like Block[{$RecursionLimit = 1000},...], which temporarily changes $RecursionLimit (Module would not have worked as it renames $RecursionLimit).

    One can also use Block to block evaluation of something, eg

    Block[{Sin}, Sin[.5]] // Trace
    (*
    -> {Block[{Sin},Sin[0.5]],Sin[0.5],0.479426}
    *)
    

    ie, it returns Sin[0.5] which is only evaluated after the Block has finished executing. This is because Sin inside the Block is just a symbol, rather than the sine function. You could even do something like

    Block[{Sin = Cos[#/4] &}, Sin[Pi]]
    (*
    -> 1/Sqrt[2]
    *)
    

    (use Trace to see how it works). So you can use Block to locally redefine built-in functions, too:

    Block[{Plus = Times}, 3 + 2]
    (*
    -> 6
    *)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Leonid's macro method ( see here ) to help me manage
How do you obtain graphic primitives and directives from a Graphics object? Leonid Shifrin
I'm trying to find a shortcut to the following loop. When developing a mathematica's
Any easy question for the Mathematica experts here: Given a list, say Clear[a, b,
I'm constructing a feed in rails and I would like the entire show path
i found this code online and im trying to compile it, but gcc keeps
I would like to define a symbol pt to hold a point (and eventually
I am writting a number of test cases in a single .mt file that
I'm trying to get the datakey value from DetailsView and paste it in a
I've figured out how to display the repeating part of a repeating decimal using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.