MathGroup Archive 2004

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

Search the Archive

Re: Sequential evaluation of lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53091] Re: [mg53076] Sequential evaluation of lists
  • From: William K Reinholtz <kirk.reinholtz at jpl.nasa.gov>
  • Date: Thu, 23 Dec 2004 07:58:31 -0500 (EST)
  • References: <200412220953.EAA04525@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Ray:

I don't think you missed anything, but still I think there's a reason 
for the behavior you note.

The documentation rightly tells you to not depend upon the order of 
evaluation for two reasons: (1) It would be difficult or impossible for 
Mathematica to do the various transformations it performs if such an 
assumption were made; and (2) It would restrict the implementation of 
the kernel unduly.

The actually Mathematica kernel does not enforce the ordering (e.g. by 
rejecting your example below, or doing it in parallel) because that 
would be quite costly to implement (if not impossible to implement) and 
there are probably many practical difficulties that would follow from 
such an implementation that would make Mathematica less useful and less general.

And so it seems a pragmatic decision to not check for violations and 
not to execute in parallel: it makes for a more useful product overall.

On Dec 22, 2004, at 1:53 AM, Ray Koopman wrote:

> When I first started using Mathematica (v2), one of the features that
> I found rather surprising is its sequential evaluation of lists, as in
>
> In[1]:= x = 0; {x++,x++,x++}
> Out[1]= {0,1,2}
>
> I had expected a warning that such code should be avoided because
> it presumed sequential evaluation, which could not be guaranteed,
> and a recommendation to treat list elements as being evaluated in
> parallel -- if not simultaneously then in no particular order.
> However, so far I have found no exception to sequential evaluation
> and no mention of it in any documentation. Have I missed something?
>


  • Prev by Date: Re: Re: Help on a recursive function
  • Next by Date: Re: Sequential evaluation of lists
  • Previous by thread: Re: Re: Sequential evaluation of lists
  • Next by thread: Re: Sequential evaluation of lists