MathGroup Archive 2010

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

Search the Archive

Re: SyntaxInformation Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110775] Re: SyntaxInformation Question
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 5 Jul 2010 21:14:19 -0400 (EDT)

On 7/5/10 at 6:02 AM, eMartinSerrano at telefonica.net (E.
Martin-Serrano) wrote:


>In the ref/SyntaxInformation in the Help there is the following
>example or explanation can be found:

>"f can have any number of arguments, but each should be a
>two-element list:"

>SyntaxInformation[f] = {"ArgumentsPattern" -> {{_, _} ...}};

>{f[{x, y}, {a, b}], f[x, {a, b}, {x, y, z}]};

>But finally '{x, y, z}' is a three elements list but it is allowed to
>pass the constrain too; and so do {v, x, y, z}, and {u, v, x, y, z},

No, not true. When you look at the documentation page for
SyntaxInformation, actually execute the cell containing:

SyntaxInformation[f] = {"ArgumentsPattern" -> {{_, _} ...}};

and note the color for z changes from blue to red (assuming
default syntax coloring) indicating a syntax error. And further
if you paste any of the above examples into the documentation
notebook you will find all of the elements of the last list past
the first two are colored red.

>and any list of whatever any other length as this {f[{x, y}, {a, b}],
>f[x, {a, b}, Sequence@@Array[x&, 100]]}.

In this last example, you have an expression being given as an
argument. There is no way for Mathematica to show an syntax
error until that expression is evaluated. So, simply typing it
in cannot cause an indication of a syntax error.

>In the example

>Options[f]={aaa->1,bbb->2,ccc -> 4};
>SyntaxInformation[f]={"ArgumentsPattern"->{_,_,OptionsPattern[]}};

>The syntax specification allows for two parameters and a list of
>options to be submitted to the function =91f[]=92.

>The following does work as expected since the following is allowed
>to pass it is right since just two parameters and a list of options
>are submitted as specified)

>f[x,y, aaa->2,bbb->3,ccc ->4];

>But the following is allowed to pass too, despite, in this case, 6
>parameters *x, y, z, k, l, m* (plus the options) are submitted
>instead of just the two specified parameters.

>f[x, y, z, k, l, m, aaa->2,bbb->3,ccc->4];

>When I say they pass, I mean nothing is colored red saying that
>something is syntactically wrong and must be corrected..

The additional arguments z, k, l, m could all evaluate as a
options rule. So, they are not colored red since they might be
valid syntax.

>This occurs  in version 7.0.1. for Windows XP SP3.

I am using version 7.0.1 on Mac OS X version 10.6.4. But I don't
believe the difference in platform is significant.



  • Prev by Date: Re: SyntaxInformation Question
  • Next by Date: Re: FindRoot with parameterized interpolated function from NDSolve
  • Previous by thread: Re: SyntaxInformation Question
  • Next by thread: Re: SyntaxInformation Question