Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Re: Big trouble with Mathematica Code parsing -- Rant.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26323] Re: [mg26301] Re: Big trouble with Mathematica Code parsing -- Rant.
  • From: "Carl K. Woll" <carlw at u.washington.edu>
  • Date: Sun, 10 Dec 2000 21:38:06 -0500 (EST)
  • References: <90kr7d$r49@smc.vnet.net> <200012100520.AAA06998@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi all,

Since many people seem to believe that the problem Louis is encountering is
not a bug, I just wanted to supply a notebook which has the parsing problem
that Louis is running into, at least when running on Windows. To reproduce
the bug, you will need to copy the notebook statement given at the end of my
post into Mathematica. Simply copying the following code will not reproduce
the bug. The notebook defines a function as follows:

f:=If[g==1,x2=1;
    x1=-d/2
]

Basically, if g equals one, then two statements are supposed to be executed.
If one executes the above code, though, you will find out that the
definition of f is

In[7]:=
?f

Global`f
f := If[g == 1, (x2 = 1; )*(x1 = -(d/2))]

As you can see, the two statements are multiplied together, and so when g is
given the value 1 and f is exectued, we get

In[13]:=
g = 1;
f

Out[14]=
-(d Null)
---------
    2

So, it appears that spurious Nulls are being introduced, just as Louis
reported. This particular bug can be remedied by any edit of the code. The
above code fragment is modified from a project I worked on a while ago,
where the bug would appear after I saved and reloaded a particular notebook.
The Wolfram recommended solution here is to set the option ShortBoxForm to
false. This worked for me, but it apparently didn't work for Louis.

The notebook follows, just copy and paste into Mathematica.

Notebook[{
Cell[BoxData[
    \(f := If[g == 1, \(\(x2 = 1;\)\[IndentingNewLine]
        x1 = \(-\(d\/2\)\)\)\[IndentingNewLine]]\)], "Input"],

Cell[BoxData[
    \(\(?f\)\)], "Input"]
},
FrontEndVersion->"4.0 for Microsoft Windows",
ScreenRectangle->{{0, 1024}, {0, 695}},
Evaluator->"Local",
WindowSize->{913, 587},
WindowMargins->{{27, Automatic}, {38, Automatic}},
Magnification->1
]

Carl Woll
Physics Dept
U of Washington

----- Original Message -----
From: "David Bailey" <db at salford-software.com>
To: mathgroup at smc.vnet.net
Subject: [mg26323] [mg26301] Re: Big trouble with Mathematica Code parsing -- Rant.


>
> "Louis M. Pecora" <pecora at anvil.nrl.navy.mil> wrote in message
> news:90kr7d$r49 at smc.vnet.net...
> > [[ This message was both posted and mailed: see
> >    the "To," "Cc," and "Newsgroups" headers for details. ]]
> >
> > {\RANT ON}
> >
> > I have just spent another 3 hours debugging Mathematica code that, for
> > some reason unclear to me, insists on putting Null's into the return
> > values, as in
> >
> >     2
> > Null  Return[{1.0,2.9}]   (in which the numbers are right, but the
> > Null's don't belong)
> >
> > Rather than just returning
> >
> > {1.0,2.9}
> >
> > Where are they coming from?  Beats me.  This is the third time in the
> > last month or so that I've spent the better part of a day (a few days
> > in some cases) trying hard to figure why Mathematica parses my code in
> > a brain-dead way.
> >
> > Beware.  Adding white space and blank lines for readability can cause
> > Null's  to appear and other problems.  I suspect this is partly related
> > to the fact that space can be taken as a multiplication, but
> > eliminating spaces and blank lines may not cure the problem.  I know.
> > I've tried.
> >
> > I've done things such as copy the code into a text editor then right
> > back to Mathematica and then it works...until I change something or
> > open up the file later and try to use it.  Then I may get a syntax
> > error or just more Nulls, again.  Sometimes recopying the code out and
> > in will fix it, again. Sometimes not.  But what a Kludge!
> >
> > Mathematica is doing things behind the scenes to the text in its
> > parsing and it messes stuff up.  Mathematica Support have responded
> > with hints such as Set Save in Box Form to False, eliminate white space
> > (there goes readability), make sure all lines end in ";" (that one, at
> > least, makes sense).  I've done it all and still have problems.
> >
> > It is ridiculous when one of the most powerful sofeware packages in the
> > world cannot parse code correctly.  It cannot handle simple, clear
> > white space correctly.  And it insists on changing things which cause
> > failures.
> >
> > These are not feature or even bugs.  They are FLAWS.
> >
> > Maybe it's the automatic indenting.  I don't know.  I am totally
> > frustrated.  If anyone knows of anyway to turn off or on some setting
> > to get this program to just handle my code sensibly, PLEASE let me
> > know.
> >
> > I hope Wolfram is listening.  There is a serious upgrade-FIX needed for
> > Mathematica 4.0.  Right now I would not recommend this program to
> > anyone in my lab.
> >
> > {\RANT OFF}
>
>
> Obviously this is a problem which other Mathematica users are not
> encountering - so you clearly must give more details in order to sort this
> out.
>
> 1) On which platform are you running Mathematica (PC,MAC, etc.)
> 2) Are you creating a notebook or writing .M files.
>
> Assuming you are creating a notebook it might be an idea to make a typical
> corrupt notebook available on the internet somewhere and post the URL to
the
> newsgroup. (You can paste bits of notebook into messages, but in this case
> it might be safer to see the file absolutely raw!).
>
> I am sure this problem does not require an "upgrade-FIX", but is the
result
> of some unusual settings in the option inspector or something similar.
>
> David Bailey
>
> Salford Software
>
>
>



  • Prev by Date: Re: Big trouble with Mathematica Code parsing --
  • Next by Date: RE: Q: Matrix Construction
  • Previous by thread: Re: Big trouble with Mathematica Code parsing -- Rant.
  • Next by thread: Call for all people presenting the Louis or Carl, Big trouble syndrom