Charles Greathouse on Sun, 10 Mar 2013 03:21:36 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: function defaults


In cases like this I just write

foo(a=-1, b=-1)={
  if(a==-1 || b==-1, error());
  \\ code
}

where -1, [], etc. is chosen as an argument which could not be valid for the function.

Charles Greathouse
Analyst/Programmer
Case Western Reserve University


On Sat, Mar 9, 2013 at 11:42 AM, Joerg Arndt <arndt@jjj.de> wrote:
The feature of all args having default 0 is
one of the few things in GP that I dislike.
I guess it is there to stay for backward compatibility.

Hence I dare to ask whether some mechanism would
be possible to disable defaults (unless given),
for individual functions.

Made up syntax:

foo(a, b)=
{
   nodefaults();
   \\ code...
}

then calling foo without both args given
should trigger an error.

(There are certainly other ways, less fugly,
to do this syntactically).

Best,   jj