Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1994

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

Search the Archive

Behavior of Opional command

  • To: mathgroup at (Mathgroup)
  • Subject: Behavior of Opional command
  • From: Scott Herod <sherod at>
  • Date: Sat, 2 Jul 1994 22:18:45 -0600 (MDT)

I have discovered a rather annoying property of the Optional command
and was hoping someone could comment.  I noticed that the problem occurs
in the X11 notebook interface and also occurs on my MAC in version 1.2.
Below is a demonstration using version 2.2.

	First I will create a file called test.m:

f[x_, y_:temp] := Block[{},
  If[y == temp, y = Pi];

	Then run this as follows:

Mathematica 2.2 for SPARC
Copyright 1988-93 Wolfram Research, Inc.
 -- Terminal graphics initialized --
In[1]:= <<test.m
In[2]:= f[a]
In[3]:= <<test.m
In[4]:= ??f
f[x_, y_:temp] := Block[{}, If[y == temp, y = Pi]; Print[x, y]]
f[x_, y_:Pi] := Block[{}, If[y == temp, y = Pi]; Print[x, y]]
In[4]:= bye


In[2] runs correctly, but when I reload test.m it has been changed.
The variable y is now supposed to default to Pi.  Admittedly, in
this case running f[a] again will have the same effect as it did
on Input line 2 because the correct version of f appears first.
However, if I had changed the file test.m, I would still be running
the old version.

Comments?  Obviously there is an easy way around the problem.  One
can simply put a line Clear[f]; in the file which defines f, but it
does seem strange that this problem occurs.

Scott A. Herod
(sherod at

  • Prev by Date: Re: Yet more Timing[10000!] ...
  • Next by Date: Re: Reading Formatted Data
  • Previous by thread: Re: Specifying rules OR "How to do complex math in Mathematica"
  • Next by thread: Re: simplification of sums