vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.14k stars 136 forks source link

Local expression in RHS with argument #168

Open jodavies opened 7 years ago

jodavies commented 7 years ago

I (accidentally) wrote an Identify statement as follows, intending test to be a CFunction, when in fact it is the name of the Local expression.

#-
Off Statistics;

Vector q1,q2;
CFunction mom,foo;

Local test = mom(q1,q2)*foo(q1);

Identify mom(q1?,q2?) = test(q1);

Print +s;
.end

This gives,

FORM 4.1 (Feb  1 2017, v4.1-20131025-295-g313a3f5) 64-bits  Run: Wed Feb  8 16:37:06 2017
    #-

   test =
       + mom(q1,q2)*foo(q1)^2
      ;

  0.00 sec out of 0.00 sec

which should yield a syntax error, should it not?

Thanks, Josh.

tueda commented 7 years ago

I agree that FORM should detect such user mistakes, though it might be a bit tricky for the compiler because global expressions in the right-hand side can have arguments, like

V q1,q2;
CF mom,foo;
.global

G test(q1) = mom(q1,q2)*foo(q1);
.store

V p1,p2;

L FF = mom(p1,p2);

id mom(q1?,q2?) = test(q1);

P;
.end

The compiler should care of (1) whether an expression in the right-hand side is global and has been stored, and then (2) the number of allowed arguments.

vermaseren commented 7 years ago

I fully agree that an error message would not be misplaced. I always learned that in writing compilers, error messges is one of the very difficult things. This seems to illustrate this. Somehow one must anticipate ‘all possible errors’. !!! I once read the following joke about it: "Just when you think you made it foolproof, somebody invents a better fool.” Just remember that when you give your programs to other people. Alternatively the Goedel, Escher, Bach book kind of explains that it is impossible.

Considering that this is an issue now, it will be picked up sooner or later.

Cheers

Jos

On 8 feb. 2017, at 17:48, Takahiro Ueda notifications@github.com wrote:

I agree that FORM should detect such user mistakes, though it might be a bit tricky for the compiler because global expressions in the right-hand side can have arguments, like

V q1,q2; CF mom,foo; .global

G test(q1) = mom(q1,q2)*foo(q1); .store

V p1,p2;

L FF = mom(p1,p2);

id mom(q1?,q2?) = test(q1);

P; .end The compiler should care of (1) whether an expression in the right-hand side is global and has been stored, and then (2) the number of allowed arguments.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/168#issuecomment-278385633, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEuB1HlAxbLv1htLQSLI5Qdo5fuhlks5rafHggaJpZM4L7DJC.