Syntax
Line 123: | Line 123: | ||
function(obj = VAR, [ ignore = FLOAT ]) | function(obj = VAR, [ ignore = FLOAT ]) | ||
function($1 = VAR, [ $2 = FLOAT ]) | function($1 = VAR, [ $2 = FLOAT ]) | ||
+ | }} | ||
[[category:Glossary]] | [[category:Glossary]] |
Revision as of 12:07, 22 March 2006
Description
Quick Reference Pass-by-reference arguments
Pass-by-value arguments
Optional arguments
The single-line function usage statement is meant to be a quick reference on how to call a function. Within the parentheses are listed the arguments (or inputs) needed to properly call the function. As not all arguments are passed to the function the same way, the syntax of the argument declaration tells the user how to pass it. Most inputs in davinci functions are davinci objects either stored in variables or created during the function call. The function usage statement will sometimes contain a declaration telling the user what type of data is expected for a specific input (in the case of explicit pass-by-reference inputs). Input Types:
Arguments passed by reference explicitly tell the user the name of the variable as it is called and manipulated within the function (ideally it is also intuitively descriptive) followed by an "=" sign and ended with the type of data (in capital letters) that should be passed (types 1 - 9) above. The format of a function usage statement with an explicit pass-by-reference argument looks like this: function1(variable_name = TYPE)
abs(obj = VAL)
The user may call this function in a couple ways. Let's take the small array of integer numbers 'a' defined below. dv> a 5x1x1 array of int, bsq format [20 bytes] 1 -6 -4 3 8
dv> abs(obj = a) 5x1x1 array of float, bsq format [20 bytes] 1.00000 6.00000 4.00000 3.00000 8.00000
dv> abs(a) 5x1x1 array of float, bsq format [20 bytes] 1.00000 6.00000 4.00000 3.00000 8.00000
Pass by Value Arguments passed by value simply state a descriptive name for the variable to indicate to the user what kind of data is required. In this case, the name of the argument should not be explicitly declared when calling the function. In general, arguments passed by value are simply ordered inputs with no labels. The format of an inexplicit pass-by-value function usage statement looks like this: function1(descriptive_name1, descriptive_name2)
ctof(object)
dv> a 124 dv> ctof(a) 255.200 dv> ctof(124) 255.200
dv> ctof(object = a) error: Unknown keyword to ufunc: ctof(... object= ...)
Optional Inputs: By allowing some inputs to be optional, davinci has the ability to have preset values that the user doesn't need to enter for the function to work. A good example of this usage is assuming an ignore value in functions like thm.deplaid. Optional inputs are enclosed by square brackets ( [ ] ) and defined as ususal. For example: function(obj = VAR, [ ignore = FLOAT ]) function($1 = VAR, [ $2 = FLOAT ]) |
Wiki Navigation Bar Contents
Contact Developers
All other topics
Last Updated: Feb-2011
More News
|