SyntaxInformation Question

• To: mathgroup at smc.vnet.net
• Subject: [mg110763] SyntaxInformation Question
• From: "E. Martin-Serrano" <eMartinSerrano at telefonica.net>
• Date: Mon, 5 Jul 2010 06:02:37 -0400 (EDT)

```Hi,

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}]};

In the first part of the example: 'f[{x, y}, {a, b}]', the list  =91{x, y}' is
a two - elements list, so is '{a, b}', then syntax constrain holds and it is
understandable for me.

In the second part of the example: 'f[x, {a, b}, {x, y, z}]', the symbol '
x=92 evaluates to a list but not necessarily to a 'two - elements list' as
demanded in the SyntaxInformation[f] = {"ArgumentsPattern" -> {{_, _} ...}}
declaration. According to the scarce explanation in the example it is not
excluded for 'x' to evaluate to a '12 - elements list=92 {x, y}'; however the
syntax constrain allows it to pass; following with the example the list '
{a, b}' is again a two - elements list, so it pass the check. 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}, and any list of whatever
any other length as this {f[{x, y}, {a, b}], f[x, {a, b},
Sequence@@Array[x&, 100]]}.

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..

I am certainly missing something important here and, clearly I do not
understand the explanation given to this very basic programming command. So
I would appreciate any clarification or help from the group.

Or maybe Wolfram should provide a complete tutorial on it or a clearer
explanation.

This occurs  in version 7.0.1. for Windows XP SP3.

E. Martin-Serrano

___________________________________________________

This e-mail and the documents attached are confidential and intended =
solely
for the addressee; it may also be privileged. If you receive this e-mail =
in
error, please notify the sender immediately and destroy it. As its =
integrity
cannot be secured on the Internet, E. Mart=EDn-Serrano liability cannot =
be
triggered for the message content. Although the sender endeavors to =
maintain
a computer virus-free network,  the sender does not warrant that this
transmission is virus-free and  will not be liable for any damages =
resulting
from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener informaci=F3n
anteriormente  pueden estar protegidos por secreto profesional y en
cualquier caso el mensaje en su totalidad est=E1  amparado y protegido =
por la
legislaci=F3n vigente que preserva el secreto de las comunicaciones, y =
por la
legislaci=F3n de protecci=F3n de datos de car=E1cter personal. Si usted =
recibe
este correo electr=F3nico por error, gracias por informar  =
inmediatamente al
remitente y destruir el mensaje. Al no estar asegurada la integridad de =
este
mensaje sobre la red, E. Mart=EDn-Serrano no se hace responsable por su
contenido. Su contenido no constituye ning=FAn  compromiso para el =
remitente,
salvo ratificaci=F3n escrita por ambas partes.  Aunque se esfuerza al =
m=E1ximo
por mantener su red libre de virus, el emisor  no puede garantizar nada =
al
respecto y no ser=E1 responsable de cualesquiera da=F1os que puedan =
resultar de
una transmisi=F3n de virus.

------=_NextPart_000_0000_01CB1C2F.C9826E00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v="urn:schemas-microsoft-com:vml" =
xmlns:o="urn:schemas-microsoft-com:office:office" =
xmlns:w="urn:schemas-microsoft-com:office:word" =
xmlns="http://www.w3.org/TR/REC-html40";>

<meta http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Courier;
panose-1:2 7 4 9 2 2 5 2 4 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
{color:blue;
text-decoration:underline;}
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
span.MathematicaFormatStandardForm
{font-family:Courier;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>

<div class=Section1>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'>Hi,<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>In the =
ref/SyntaxInformation
in the Help there is the following example or explanation can be =
found:<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'>&quot;</span></font><span
class=MathematicaFormatStandardForm><font =
face=Courier>f</font></span> can have
any number of arguments, but each should be a two-element list:&quot; =
<o:p></o:p></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'>SyntaxInformation[f] =
{&quot;ArgumentsPattern&quot; -&gt; {{_, _} =
...}};<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>{f[{x, y}, {a, =
b}], f[x,
{a, b}, {x, y, z}]};<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal =
style='margin-right:-.5in;text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>In the first =
part of the
example: 'f[{x, y}, {a, b}]', the list  &#8216;{x, y}' is a two - =
elements
list, so is '{a, b}', then syntax constrain holds and it is =
understandable for
me.<o:p></o:p></span></font></p>

<p class=MsoNormal =
style='margin-right:-.25in;text-autospace:none'><font
size=3 face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>In the second =
part of the
example: 'f[x, {a, b}, {x, y, z}]', the symbol ' x&#8217; evaluates to a =
list
but not necessarily to a 'two - elements list' as demanded in the =
SyntaxInformation[f]
= {&quot;ArgumentsPattern&quot; -&gt; {{_, _} ...}} declaration. =
According to
the scarce explanation in the example it is not excluded for 'x' to =
evaluate to
a '12 - elements list&#8217; {x, y}'; however the syntax constrain =
allows it to
pass; following with the example the list ' {a, b}' is again a two - =
elements
list, so it pass the check. 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}, and any list of whatever any other length as this {f[{x, y}, =
{a, b}],
f[x, {a, b}, Sequence@@Array[x&amp;, =
100]]}.<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>In the example =
<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'>Options[f]={aaa-&gt;1,bbb-&gt;2,ccc
-&gt; 4};<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'>SyntaxInformation[f]={&quot;ArgumentsPattern=
&quot;-&gt;{_,_,OptionsPattern[]}};
<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>The syntax =
specification allows
for two parameters and a list of options to be submitted to the function
&#8216;f[]&#8217;.<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>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)<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span lang=ES =
style='font-size:12.0pt'>f[x,y,
aaa-&gt;2,bbb-&gt;3,ccc -&gt;4];<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span lang=ES =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>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.<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span lang=ES style='font-size:12.0pt'>f[x, =
y, z, k, l,
m, aaa-&gt;2,bbb-&gt;3,ccc-&gt;4];<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span lang=ES =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>When I say =
they pass, I
mean nothing is colored red saying that something is syntactically wrong =
and
must be corrected.. <o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>I am certainly =
missing
something important here and, clearly I do not understand the =
explanation given
to this very basic programming command. So I would appreciate any =
clarification
or help from the group.<o:p></o:p></span></font></p>

<p class=MsoNormal style='text-autospace:none'><font size=3
face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'>Or maybe Wolfram should provide a complete tutorial on it or a =
clearer
explanation.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'>This occurs  in version 7.0.1. for Windows XP =
SP3.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'>E. Martin-Serrano<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span =
style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span =
style='font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 face=Arial><span =
style='font-size:10.0pt;
font-family:Arial'>___________________________________________________</s=
pan></font><o:p></o:p></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:
12.0pt'>This e-mail and the documents attached are confidential and =
intended
solely for the addressee; it may also be privileged. If you receive this =
e-mail
in error, please notify the sender immediately and destroy it. As its =
integrity
cannot be secured on the Internet,&nbsp;E. Mart=EDn-Serrano liability =
cannot be
triggered for the message content. Although the sender endeavors to =
maintain a
computer virus-free network,  the sender does not warrant that this
transmission is virus-free and  will not be liable for any damages =
resulting
from any virus transmitted. <br>
<br>
contener
informaci=F3n confidencial&nbsp; destinada solamente a la(s) persona(s)
mencionadas anteriormente  pueden estar protegidos por secreto =
profesional y en
protegido por
la legislaci=F3n vigente que preserva el secreto de las comunicaciones, =
y por la
legislaci=F3n de protecci=F3n de datos de car=E1cter personal. Si usted =
recibe este
correo electr=F3nico por error, gracias por informar&nbsp; =
inmediatamente al
remitente y destruir el mensaje. Al no estar asegurada la integridad de =
este
mensaje sobre la red, E. Mart=EDn-Serrano no se hace responsable por su =
contenido.
Su contenido no constituye ning=FAn  compromiso para el remitente, =
salvo
ratificaci=F3n escrita por ambas partes.  Aunque se esfuerza al =
m=E1ximo por
mantener su red libre de virus, el emisor  no puede garantizar nada al =
respecto
y no ser=E1 responsable de cualesquiera da=F1os que puedan resultar de =
una
transmisi=F3n de virus. </span></font><font size=2 face=Arial><span =
style='font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p=
>

<p class=MsoNormal><font size=3 face="Times New Roman"><span =
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_000_0000_01CB1C2F.C9826E00--

```

• Prev by Date: Re: Display/manipulating numeric values inside a DynamicModule[]
• Next by Date: Change Default Button Method
• Previous by thread: Re: a 4d algebraic geometry problem
• Next by thread: Re: SyntaxInformation Question