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: Call for all people presenting the Louis or Carl, Big trouble syndrom

  • To: mathgroup at smc.vnet.net
  • Subject: [mg26342] Re: Call for all people presenting the Louis or Carl, Big trouble syndrom
  • From: Carl Woll <carlw at u.washington.edu>
  • Date: Tue, 12 Dec 2000 02:54:53 -0500 (EST)
  • References: <90kr7d$r49@smc.vnet.net> <200012100520.AAA06998@smc.vnet.net> <200012110238.VAA10112@smc.vnet.net> <3A34D29D.81F1ABA@club-internet.fr> <3A353FC3.71C12265@u.washington.edu> <3A355743.838D4EFB@club-internet.fr>
  • Sender: owner-wri-mathgroup at wolfram.com

Jacqueline,

See my comments below.

Jacqueline Zizi wrote:

> 1) Carl Woll wrote:
>
> > Jacqueline,
> >
> > Thank you for taking an interest in this problem.
> >
> > I'm afraid I disagree with your assessment of the situation.  First, there is nothing wrong with using the If
> > command in the form
> >
> > If[condition, expr1; expr2]
>
> Oh, yes there is! This is ambiguous as I wrote in my precedent post, as 2 interpretations are possible. I don't
> believe that you can find only one example of that  in all The Book. I consider that what is in the book is OK,
> not the other things.
>
> Write If[condition, (expr1; expr2)] will avoid such ambiguity.
>

Since Mathematica has a well defined precedence for the operators, there really shouldn't be any ambiguity in the
above statement. It should either be interpreted as If[condition,CompoundExpression[expr1,expr2]] or it should be
interpreted as If[condition,Times[CompoundExpression[expr1,Null],expr2]]. The normal interpretation that
Mathematica makes (and the one most people would expect) is the first (try some test cases). Sometimes, for no
apparent reason Mathematica chooses to use the second interpretation. This is clearly a bug.

>
> 2) Second, Mathematica should never intrepret
>
> stmt1;
> stmt2;
>
> as
>
> (stmt1;)*(stmt2;)
>
> Why not? Suppose  you want to do the product of the results of evaluations of smt1 and smt2?
>
> When I want to do separate different  things I just put them in 2 different cells or else I write
> (stmt1; stmt2), short for CompoundExpression [stmt1, stmt2]. And doing so I have never met your problem. That is
> why I'm still curious about it.
>
> Jacqueline

Why would you ever want to multiply the output of stmt1; with stmt2;. In each case the output is Null (note the
presence of the semicolon), so you will end up with Null^2. Can this ever be a useful output?

Any time you are trying to write a complex function, you will need to execute more than one statement, and of
course a function definition needs to be in one cell. Putting things in two different cells is not an option here.
I think you will find that you are a minority of 1 if you always use (stmt1; stmt2)  instead of stmt1; stmt2.
Moreover, it is not clear to me that this should really help. What is the difference between

stmt1;
stmt2

and

(
stmt1;
stmt2
)

Why should these external parenthesis prevent Mathematica from interpreting the second possibility in the same way
as the first?

Still, you didn't respond to the most critical aspect of this whole issue. Sometimes Mathematica interprets stmt1;
stmt2 as CompoundExpression[stmt1,stmt2] and sometimes it interprets it as
Times[CompoundExpression[stmt1,Null],stmt2].  Clearly, this is not acceptable.

Carl Woll
Physics Dept
U of Washington




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