MathGroup Archive 1999

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

Search the Archive

Re: MyPrependTo

  • To: mathgroup at
  • Subject: [mg16011] Re: MyPrependTo
  • From: Jens-Peer Kuska <kuska at>
  • Date: Sat, 20 Feb 1999 02:52:03 -0500
  • Organization: Universitaet Leipzig
  • References: <7ag26u$> <7aj9no$>
  • Sender: owner-wri-mathgroup at

Hi Dan,

_IT_IS_ILLEGAL_ (!!!!) to assign a "function parameter". Because
don't know what function parameters are. 

the definition someFunc[a_,b_]:=doSomething gives a pattern ! a_ and b_
are *not* paramters in the sense of C, FORTRAN, Pascal ...
a_ and b_ are patterns and can stand for any expression value.

A pattern is some general construct. Let me give you an example.
In the natural language "dog" in "Any dog eat meat." is a pattern
you can match this pattern by "Fluffy is a dog" (dog-> Fluffy)
and get a true sentence. If you assign a pattern in the expression
you say all dogs are Fluffy and that is clearly nonsense.

In fact it is so that assigments to pattern in function rules
can mix up Mathematica completly. In earlyer versions the kernel
crashes or give total strange results. Now only the strange results
are present. Will Self gaves a nice example of the unpredicable
nonsense produced by Mathematica when a pattern inside a
function definition get an assigment.


Dan Truong wrote:
> > In[2]:=
> > push[someStack_, elt_] := (someStack = Prepend[someStack, elt];)
> Is it legal in Mathematica to assign a function parameter?
> I think not, because they are avaluated before going in the
> function body (ie, parameters are passed by value, not by
> reference or pointers)
> The solution is to use a golbal stack parameter, or to use
> Return[]
> Push[...] := ( Return[Prepend[...]]);
> e = Push[e,1];
> BTW: does anyone know how to pass a pointer to an object
> so it can be modified and returned? HoldFirst etc. do not
> do that.
> --
> Dan N. Truong,  IRISA, Campus de Beaulieu, 35042 Rennes Cedex, FRANCE
> tel:(+33)2 99 84 25 39            fax:(+33)2 99 84 25 28
> mailto:dtruong at 
> gsm:06 14 78 06 95 ->

  • Prev by Date: Re: HELP: Plot[]ing composite functions
  • Next by Date: Re: 3D data graphing
  • Previous by thread: Re: MyPrependTo
  • Next by thread: Re: Re: MyPrependTo