MathGroup Archive 2007

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

Search the Archive

MakeExpression problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg77095] MakeExpression problem
  • From: Hannes Kessler <HannesKessler at hushmail.com>
  • Date: Sun, 3 Jun 2007 06:13:13 -0400 (EDT)

Hello,

here is a small package defining and using a generic MakeExpression
interpretation rule:

BeginPackage["DoubleLongRightArrow`"];
{test1,test2,a,b,interpretation};
Begin["`Private`"];
MakeExpression[RowBox[{x_,"\[DoubleLongRightArrow]",y_}],form_]:=
   MakeExpression[RowBox[{"interpretation"}],form];
test1=a\[DoubleLongRightArrow]b;
(*The following assigment forces an interpretation by additional
application of //ToBoxes//ToExpression*)
test2=a\[DoubleLongRightArrow]b//ToBoxes//ToExpression;
End[];
EndPackage[];

Here is a small notebook which calls the package.
The typesetted \[DoubleLongRightArrow] looks in the notebook like ==>.

Needs["DoubleLongRightArrow`"];
(*The following expression is correctly interpreted in the notebook:*)
In[] a==>b
Out[] interpretation
(*The expression read in the package is not interpreted:*)
In[] test1
Out[] a==>b
(*Only the second expression converted first to boxes and then again
to an expression is interpreted correctly*)
In[] test2
Out[] interpretation

My question is, how can I define an interpretation rule in a package
and use it in the same or other packages, not only in notebooks?

Regards,
Hannes Kessler



  • Prev by Date: Re: pure function to generate a list of integrals
  • Next by Date: Re: pure function to generate a list of integrals (correction)
  • Previous by thread: Re: simple question
  • Next by thread: Re: MakeExpression problem