HP Forums
Idea: new keyword OPERATOR - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Idea: new keyword OPERATOR (/thread-4131.html)



Idea: new keyword OPERATOR - compsystems - 06-11-2015 12:02 PM

Hello, sorry for my bad English, my multilingual chip is damaged =(

I want to create a new library of functions, but using operator notation, nonfunctional

functions are currently defined as follows

functionname (arg1, arg2)
Begin
...
End;

I think, should add a new keyword Operator

Operator arg1 functionname arg2;
Begin
...
End;

Operator arg1 ⊗ arg2;
Begin
...
End;

Operator arg1 ⊕ arg2;
Begin
...
End;

Operator arg1 ⊂ arg2;
Begin
...
End;

Good idea?
+1 or -1

The hp48 allowed to define functions as operators


RE: Idea: new keyword OPERATOR - StephenG1CMZ - 10-12-2015 07:03 PM

Having the option to use infix notation when you are used to it can certainly be clearer, but your syntax looks like you would only use the infix notation for the functions you define.

I would suggest instead a syntax more like that used in POP-2:

Definition:

EXPORT matrixmultiply(a,b)
Begin
End -> "***"; //map this procedure to infix symbol ***

Call either as now:
Matrixmuliply(a,b); //useful if you don't know the infix symbol
Or in infix if you like:
A *** b; //more readable

(In fact, in POP-2 you could just use a single "*", and it could work out which multiply you needed based on parameter types:
two reals => internal multiply,
Two matrices => use defined matrix multiply procedure etc.)