Re: Re: scope all wrong? in Mathematica 4.1

*To*: mathgroup at smc.vnet.net*Subject*: [mg31898] Re: [mg31847] Re: scope all wrong? in Mathematica 4.1*From*: David Withoff <withoff at wolfram.com>*Date*: Mon, 10 Dec 2001 06:14:40 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

> I have found a feature amongst your examples that came as a surprise: the > way in which SetDelayed is evaluated. ... the rule is stored is as expected > from the above, but it seems that after making later rules; some kind of > evaluation is triggered, as though trying to evaluate the left sides using > the other rules (the rules themselves are not altered). These evaluations > may be due to working out the order in which to store or replace existing > ones. Yes. I thought that this was already well-known, at least to people interested in Mathematica trivia, which is about all that this really is. It has nothing to do with any of the other issues raised in this discussion, and is certainly not a fundamental feature of the programming language. The current strategy for ordering rules involves some evaluations of parts of previous rules. This is essentially just a curiosity which is rarely encountered and which has no known adverse effects in any practical examples. > It seems to me that it would be better if these evaluations were done > in private. While it might be better to develop some other strategy for ordering rules, as a practical matter there is no such thing as doing evaluations in private, since evaluations can have irreversible effects. For example, one might consider what should happen if one of those evaluations loaded a package, or updated the random number generator, or evaluated Quit[]. > However, the same kind of evaluations will occur when the rules > are used, and any unwanted assignments can be avoided in both circumstances > by suitable localisation of symbols inside tests and conditions, though > unwanted printing would still occur. Exactly. In other words, if those evaluations are a problem when the rules are ordered then they is also a problem when the rules are used, and the programmer will have to figure out a way to deal with that regardless of whatever else happens. Dave Withoff Wolfram Research