Re: MakeExpression problem

• To: mathgroup at smc.vnet.net
• Subject: [mg77173] Re: MakeExpression problem
• From: Hannes Kessler <HannesKessler at hushmail.com>
• Date: Tue, 5 Jun 2007 06:41:32 -0400 (EDT)
• References: <200706031013.GAA02923@smc.vnet.net><f40g34\$5uk\$1@smc.vnet.net>

```On 4 Jun., 09:47, "Chris Chiasson" <c... at chiasson.name> wrote:
> Warning: I do not fully understand how operators are defined in
> Mathematica, however I have some idea.
>
> AFAIK, a MakeExpression rule is useless in a non-notebook environment
> because the commands are (then) not represented as boxes.
>
> You do not have to catch the DoubleLongRightArrow operator at the
> "parsing" stage. Once
> a==>b is read into Mathematica, it becomes the following expression (AFAIK):
>
> DoubleLongRightArrow[a,b]
>
> You can easily define a DownValue for DoubleLongRightArrow to do what you want.
>
> This method should work for both notebooks and package files.
>
> On 6/3/07, Hannes Kessler <HannesKess... at hushmail.com> wrote:
>
>
>
>
>
> > 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
>
> --http://chris.chiasson.name/- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Thank you Chris, I think this solves my problem.

```

• Prev by Date: Re: Very Strange Behaviour about something Very Simple
• Next by Date: RE: RE: simple question
• Previous by thread: Re: Re: MakeExpression problem
• Next by thread: Re: pure function to generate a list of integrals (correction)