Spreadsheet applications provide various functions that can be employed to perform computations and other operations. Typically, during development for each spreadsheet function the behavior of that function must be specified by a developer explicitly in a definition of the function, including the behavior of the function with respect to arguments of the function.
Various embodiments of the invention are disclosed in the following detailed description and the accompanying drawings.
The invention can be implemented in numerous ways, including as a process; an apparatus; a system; a composition of matter; a computer program product embodied on a computer readable storage medium; and/or a processor, such as a processor configured to execute instructions stored on and/or provided by a memory coupled to the processor. In this specification, these implementations, or any other form that the invention may take, may be referred to as techniques. In general, the order of the steps of disclosed processes may be altered within the scope of the invention. Unless stated otherwise, a component such as a processor or a memory described as being configured to perform a task may be implemented as a general component that is temporarily configured to perform the task at a given time or a specific component that is manufactured to perform the task. As used herein, the term ‘processor’ refers to one or more devices, circuits, and/or processing cores configured to process data, such as computer program instructions.
A detailed description of one or more embodiments of the invention is provided below along with accompanying figures that illustrate the principles of the invention. The invention is described in connection with such embodiments, but the invention is not limited to any embodiment. The scope of the invention is limited only by the claims and the invention encompasses numerous alternatives, modifications, and equivalents. Numerous specific details are set forth in the following description in order to provide a thorough understanding of the invention. These details are provided for the purpose of example, and the invention may be practiced according to the claims without some or all of these specific details. For the purpose of clarity, technical material that is known in the technical fields related to the invention has not been described in detail so that the invention is not unnecessarily obscured.
As used herein, the term “cell” refers to a cell associated with at least standard spreadsheet functionality. The term “at least standard spreadsheet functionality” in the context of a cell includes the ability to define the content of one cell in such a way that the content of the one cell is determined based at least in part on the content of one or more other cells, and the content of the one cell is updated automatically without further human action if the content of one or more of the one or more other cells is changed. A spreadsheet cell may include a formula that comprises one or more predefined and/or custom functions. The definition of a function may specify one or more required and/or optional arguments. Although many of the examples provided herein are with respect to a spreadsheet application, the techniques described herein may be similarly employed with respect to any application, spreadsheet or otherwise.
As disclosed herein, in some embodiments, the behavior of a function with respect to its arguments is at least in part parameterized. That is, the behavior associated with the arguments of a function is at least in part abstracted or factored out from the rest of the function definition. Such an abstraction of function argument behavior facilitates reuse of the associated code across a plurality of functions with respect to which the behavior is applicable. Code reuse has many advantages including providing consistency across various functions whose arguments exhibit similar behavior, reduced errors or bugs, easier implementation of functions during development, etc. As further described below, in some embodiments, at least some standard properties associated with function arguments are parameterized and specified separately from the rest of the function definition. As used herein, the term “parameterize” refers to abstracting a behavior of a function (e.g., a behavior of a function with respect to an argument of the function) from the rest of the definition of the function.
Although many of the examples described herein are with respect to parameterizing and separately specifying the behavior of a function with respect to its arguments, in other embodiments, the disclosed techniques may be employed with respect to any other behavior associated with a function.
A function may have one or more arguments. The function arguments of functions may be associated with various properties. For example, some function arguments may be required while others may be optional. Some function arguments may be restricted to one or more prescribed data types, and/or one or more prescribed data types may be disallowed for some function arguments. Some function arguments may be restricted to values within prescribed ranges. Some functions arguments may be restricted to one or more prescribed (mode) values. Function arguments comprising Boolean values may be coerced or converted into numerical values (e.g., 1 for TRUE and 0 for FALSE) by some functions but may be disallowed by other functions. Function arguments comprising header row and/or column references may be ignored or disallowed by some functions but accepted by other functions. Vectors (e.g., a range, list, or array) may be accepted for some function arguments while some function arguments may be restricted to scalar values. Function arguments comprising referenced cells whose values have certain data types may be ignored or skipped by some functions while directly entered arguments of those same data types may be individually considered by the functions. In some embodiments, errors may be specified for function argument values that are not accepted and/or are disallowed. Although examples of some properties that may be associated with function arguments have been provided, various function arguments may be associated with any one or more applicable properties.
To illustrate an example of some properties associated with function arguments, consider, for instance, the plus (+) operator and the SUM function in typical spreadsheet applications. Numerical arguments associated with a plus operator and numerical arguments associated with a SUM function are added together. In some cases, the plus operator permits operands that are numerical values expressed as strings. In such cases, the numerical values expressed as strings are converted into corresponding numerical values. For example, the computation 1+“1”+2 yields a result of 4 since the string “1” is converted into a numerical value of 1. However, a computation such as 1+2+“q” results in an error since the string “q” does not comprise a numerical value expressed as a string. Similarly, the SUM function permits numerical values expressed as strings in the cases in which the arguments are directly specified. For example, the computation SUM(1,“1”,2) yields a result of 4 since the string “1” is converted into a numerical value of 1, and a computation such as SUM(1,2,“q”) results in an error since the string “q” does not comprise a numerical value expressed as a string. However, in the cases in which one or more arguments of the SUM function comprise cell references, the cell references that are associated with non-numerical values are ignored in the computation. For example, assume that cells B1, B2, B3, and B4 have values 1, “1”, 2, and “q”, respectively. In this case, the computation SUM(B1:B3) yields a result of 3 since the string “1” in cell B2 is ignored, and the computation SUM(B1:B4) also yields a result of 3 since the string “1” in cell B2 and the string “q” in cell B4 are ignored. Thus, as is apparent from the given examples, the properties of various function arguments may depend on the context in which they are used.
In some embodiments, standard or common code associated with the manner in which functions behave with respect to their associated function arguments (e.g., code associated with accessing or checking argument values, converting Booleans to numerical values, ignoring empty cells in a range or those that include non-numerical values, etc.) that is not specific to actual function behavior is at least in part abstracted from the function definitions of at least a subset of spreadsheet functions so that, for example, the code can be reused. In some such cases, various function argument properties are parameterized, and values of such function argument properties for one or more functions are separately specified and collectively stored in a database.
As described, in some embodiments, various properties associated with function arguments are parameterized, and the specification of such properties is abstracted from other parts of a function definition.
Although the foregoing embodiments have been described in some detail for purposes of clarity of understanding, the invention is not limited to the details provided. There are many alternative ways of implementing the invention. The disclosed embodiments are illustrative and not restrictive.