RE: Re: Length of actual parameters in a function call.

*To*: mathgroup at smc.vnet.net*Subject*: [mg47193] RE: [mg47124] Re: Length of actual parameters in a function call.*From*: "E. Martin-Serrano \(Houston - USA\)" <eMartinSerrano at houston.rr.com>*Date*: Mon, 29 Mar 2004 04:22:39 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

Many Thanks. -----Original Message----- From: Paul Abbott [mailto:paul at physics.uwa.edu.au] To: mathgroup at smc.vnet.net Subject: [mg47193] Re: [mg47124] Re: Length of actual parameters in a function call. At 1:30 PM +0000 26/3/04, Andrzej Kozlowski wrote: >On 26 Mar 2004, at 08:56, Paul Abbott wrote: > >>In article <c3udpe$9om$1 at smc.vnet.net>, >> "E. Martin-Serrano" <eMartinSerrano at houston.rr.com> wrote: >> >>>A few weeks ago, reviewing some tutorials on pattern matching and error >>>handling, I came across an undocumented function to monitor the number of >>>parameters submitted to a function in a call; but somehow I lost its track >>>later. I guess that it must be something well-known by our specialists. Any >>>help about where to locate it? >>> >>>The undocumented feature helps in tracking situations as when we define >>>"MyFunction[a_,b_,c_]:= something" and then it is called as "myFunction[a]" >>>leaving the function unevaluated. >> >> MyFunction[a_, b_, c_] := something >> >> MyFunction[args___] := Null /; Length[{args}] != 3 && >> Message[MyFunction::argx, MyFunction, Length[{args}]] >> >> MyFunction[a] >> >>Cheers, >>Paul >> >>-- >>Paul Abbott Phone: +61 8 9380 2734 >>School of Physics, M013 Fax: +61 8 9380 1014 >>The University of Western Australia (CRICOS Provider No 00126G) >>35 Stirling Highway >>Crawley WA 6009 mailto:paul at physics.uwa.edu.au >>AUSTRALIA http://physics.uwa.edu.au/~paul >> >> > >This does not seem to produce the correct message; I think you need >something like: > > MyFunction[a_, b_, c_] := something > >MyFunction::"argx" = "MyFunction called with `1` arguments, 3 arguments are \ >expected." > >MyFunction[args___] := Null /; Length[{args}] != 3 && > Message[MyFunction::argx, Length[{args}]] > > >MyFunction[a] Actually, I wanted to use the appropriate built-in message. Having another look at Messages.m in SystemFiles`Kernel`TextResources`English`, argrx, is the one to use: Clear[MyFunction] MyFunction[a_, b_, c_] := something MyFunction[args___] := Null /; Length[{args}] != 3 && Message[MyFunction::argrx, MyFunction, Length[{args}],3] MyFunction[a] Cheers, Paul