HP Forums
cross calling ppl and #cas ??? - 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: cross calling ppl and #cas ??? (/thread-4872.html)



cross calling ppl and #cas ??? - ji3m - 10-04-2015 12:21 PM

So what are the argument and evaluation rules when

(1) a ppl function calls a #cas func
(2) a #cas function calls ppl
(3) a ppl fun passes cas variables

I get different results and sometimed brutsl crashes
depending on the args and functions.


RE: cross calling ppl and #cas ??? - cyrille de brébisson - 10-05-2015 07:13 AM

Hello,

Easy answer: I can't even remember!

Ok, looking in the code, here are the rules:
From PPL to CAS
- Parameters are NOT evaluated prior to the CAS call Unless it is a list
- All local variables in the parameters are replaced by their values (because CAS does not have access to local variables)
- Parameters which are Strings are parsed by the CAS parser
- CAS default variable is changed to X, Y and theta depending on the current app
- CAS function is evaluated
- CAS default variable is restored
- CAS Result is transformed into PPL construct and returned

from CAS to PPL
- All arguments are evaluated
- Arguments are transformed into PPL constructs and PPL function is called
- Result is transformed back into CAS and returned

Cyrille


RE: cross calling ppl and #cas ??? - ji3m - 10-05-2015 03:27 PM

I presume you mean the CAS (....) call.

How about calling a #cas function.. from ppl?

e.g.

#cas f (a,b):=......#end

then in ppl call f

a:= f (n,m);

Anything different here?


RE: cross calling ppl and #cas ??? - Han - 10-05-2015 03:36 PM

(10-05-2015 03:27 PM)ji3m Wrote:  I presume you mean the CAS (....) call.

How about calling a #cas function.. from ppl?

e.g.

#cas f (a,b):=......#end

then in ppl call f

a:= f (n,m);

Anything different here?

He means all instances of calling a program or command name that is associated with the CAS side of things. So whether it is a function you created using #cas or a built-in CAS command, what Cyrille posted is an explanation of how inputs are parsed when calling a CAS command/program from within a PPL program or calling a PPL program from within a CAS program. The CAS() command is a PPL command as is the CAS.command() construct.