MathGroup Archive 1995

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

Search the Archive

Re: Module/Block problem (passing pointers?)


> If it were possible to pass pointers it would be easy to send test2 the
> flag pointer and then check it in test1.  But I believe that Mathematica
> can only pass values, correct?

Not correct. The paradigm of in-out (or VAR, or reference) parameters
can be implemented like this (see "The Mathematica Programmer", APP, 1994,
Chapter 1):

SetAttributes[test2, HoldFirst]

test2[s_Symbol] := (
	s = True;
)


In[3]:= f = False;

In[4]:= test2[f]

In[5]:= f

Out[5]= True


Now you can do:

test1 := Module[{flag},
  Print["1,1 ",flag];
  test2[flag];
  Print["1,2 ",flag];
]

Roman Maeder


  • Prev by Date: Re: Replacing terms and expanding one at a time
  • Next by Date: Re: Module/Block problem (passing pointers?)
  • Previous by thread: MLReady()
  • Next by thread: Re: Module/Block problem (passing pointers?)