Functions in UV are implemented as subroutines.  That is, the following are 
equivalent.

FUNCTION MyName(Arg1,Arg2)
* my code here
RETURN(Result)

SUBROUTINE MyName(Result,Arg1,Arg2)
* my code here
RETURN

When you use CALL, you use the actual catalog name (whether it's in VOC or 
GLOBAL.CATDIR).  That name is replaced with the entrypoint address and cached.  
If you use indirect CALL (that is, CALL @SUBNAME) you've pre-loaded the catalog 
name into that local variable (SUBNAME) and its value and data type are changed 
so that the local variable is used as the cache.  This is allegedly slightly 
faster, but the difference is not noticeable even on moderately fast hardware.

However, when you use DEFFUN what you are actually doing is creating a variable 
name.  This must conform to the rules for naming variables, one of which is 
that it must begin with an alphabetic character.  The main reason for needing 
DEFFUN for locally cataloged functions is to differentiate (for the compiler) 
"MYNAME(" as identifying a dimensioned array from "MYNAME(" as a function 
reference.

Therefore some other mechanism is needed to tie this variable name to the 
reference to the globally cataloged function, and that's where the CALLING 
clause comes in.

You can't (because of variable name rules) use :
  DEFFUN !MYFUNC(X1, X2)
  RESULT = !MYFUNC(Arg1, Arg1)

But you CAN use:
  DEFFUN MYFUNC(X1, X2) CALLING !MYFUNC
  RESULT = MYFUNC(Arg1, Arg2)

Hope this helps.
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to