MathGroup Archive 2009

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

Search the Archive

Re: Re: Show doesn't work inside Do loop ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102015] Re: [mg101973] Re: Show doesn't work inside Do loop ?
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sun, 26 Jul 2009 03:57:13 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <32390795.1248259308283.JavaMail.root@n11> <h4951e$q2e$1@smc.vnet.net> <200907241016.GAA17537@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

The trouble, of course, is that Print is not an "ordinary" function that 
  returns a (non-Null) result; rather, it sends what is to be printed to 
the $Output channel.  And a quick experiment confirms this:

   x = Print["Hello, world!"]
Hello, world!
   x
(* no output appears *)

By contrast, Show does return a result.

As Do returns no result, the only way, really, to get output displayed 
during execution of the Do loop is to use something like Print that is 
not actually returning a result.

So of course the inexperienced user is perplexed here.

Now the issue becomes one of language design:  Should the Mathematica 
language -- or any computer language, for that matter -- be designed 
primarily with the inexperienced user in mind?


AES wrote:
> In article <h4951e$q2e$1 at smc.vnet.net>,
>  "David Park" <djmpark at comcast.net> wrote:
> 
>> A Do loop never generates any output on its own. Print generates the output,
>> so add a Print header to the Show statement.
> 
> David,
> 
> Can't quarrel with your overall response here -- but might you also 
> agree that your two statements above are in a real sense contradictory.
> 
> To put it another way:
> 
> *  Show, executed in a single cell, sure generates output.
> 
> *  Print, executed in a single cell, sure generates output.
> 
> So, I think my off-cited even if mythical "ordinary user" would very 
> reasonably conclude that wrapping Show *or* Print in a Do should produce 
> multiple versions of the single-cell output.  Producing multiple 
> versions of what some single-cell expression does is what Do loops are 
> *supposed* to "do" -- nicht wahr?  And "Show" is as an imperative a verb 
> as is "Print".
> 
> I'm not really interested in why Print can Do, and Show can't.  I'm just 
> noting that this is an easily and reasonably misunderstood situation, 
> and that's unfortunate.
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: Show doesn't work inside Do loop ?
  • Next by Date: Re: Logarithmic ticks in SectorChart
  • Previous by thread: Re: Show doesn't work inside Do loop ?
  • Next by thread: Re: Re: Re: Show doesn't work inside Do loop ?