MathGroup Archive 2005

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

Search the Archive

Re: Zero argument functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61736] Re: Zero argument functions
  • From: albert <awnl at arcor.de>
  • Date: Thu, 27 Oct 2005 05:54:30 -0400 (EDT)
  • References: <djn3hk$ilk$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
 
> For a "function" with no argument, what is the difference between:
> 
> myFunc:=(whatever)
> 
> and
> 
> myFunc[]:=(whatever)
> 
> I find the first syntax simpler, but there are many built-in
> Mathematica functions that use the second one.

myFunc:=whatever changes OwnValues[myfunc], myFunc[]:=whatever adds a rule
to DownValues[myFunc]. In the letter case you can add definitions with
arguments or options, if you later think that's usuful/necessary. Except
for that I can't think of anything that matters in everyday programming.
Basically it is a matter of taste. Many people, including me and obviously
some at Wolfram, prefer to be able to distinguish by mere syntax whether
something holds a fixed value or calculates a result, so I usually use
empty brackets when something is calculated and no empty brackets if
something just holds a value.

albert


  • Prev by Date: Mathematica and version control systems
  • Next by Date: Re: tensor product
  • Previous by thread: Re: Zero argument functions
  • Next by thread: Mathematica and version control systems