Re: tag Times protected??

*To*: mathgroup at smc.vnet.net*Subject*: [mg13454] Re: [mg13419] tag Times protected??*From*: David Withoff <withoff>*Date*: Fri, 24 Jul 1998 01:45:39 -0400*Sender*: owner-wri-mathgroup at wolfram.com

> I am writing with an annoying behavior in Mathematica, which I hope has > a logical explanation. I have found that sometimes when I write two > consecutive lines which display output, I get the message "tag Times > protected" > > Say I write: > > pe[j] = pate[[1]] > ph[j] = path[[1]] > peh[j] = pateh[[1]] > > where pate, path, and pateh are lists. So this is merely an assignment > exercise, but Mathematica somehow thinks that I've written instead: > > pe[j] = pate[[1]]ph[j] = path[[1]]peh[j] = pateh[[1]] > > i.e. I'm trying to multiply the three. Of course, this is an error, so > Mathematica gives a warning message. But, if I write the same > expression as: > > pe[j] = pate[[1]]; > ph[j] = path[[1]]; > peh[j] = pateh[[1]]; > > the problem disappears, and Mathematica doesn't want to multiply the > three. > > Does anyone know why this is happening, or more importantly, how to > prevent this behavior? I'd appreciate any help. > > Jordan The only way to be certain that a collection of inputs will be separated as you want is to include the necessary parentheses, semicolons, etc., to make the input unambiguous, or to put each input in a separate cell. Otherwise, the computer must guess where one input ends and the next input begins, and those guesses won't necessarily be what you want. In most computer languages this type of input would be a syntax error. In most computer languages, the extra line-continuation marks and other notations that disambiguate the input are required. In Mathematica that you don't have to do that, but you might want to do it anyway. It is possible that the heuristics that are used in Mathematica for guessing where one input ends and the next input begins will be changed in future versions of Mathematica. This is a difficult task, especially in typeset input with automatic line-breaking, where line breaks can change depending on such things as the width of the notebook window. If the only thing that distinguishes one input from another is that the inputs are on separate lines, it is possible, for example, if the heuristics aren't quite right, for the meaning of the input to change when you change the width of the notebook window. That would be bad. In any case, the answer to your question is that this happens because the computer isn't always able to guess where you want to separate the inputs, and the solution is to add disambiguating syntax, or to put the inputs in separate cells. Dave Withoff Wolfram Research