Proposal argument List
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
## Scenario
For some reason, the OOP programming is not a reliably pattern in data science programming. Due to the reason of functional programming have the characteristic of identical output with the identical input, so that the functional programming is the most favorite programming pattern in the data science application programming. For some data science function api that have a very deep function stacks, like [heatmap.2 plot API function in R language](https://www.rdocumentation.org/packages/gplots/versions/3.0.1/topics/heatmap.2), for passing the values to the internal function calls, the most outside function always have a lot of function parameters. And this will caused a big problem for passing the correct parameter values to the internal functions.
Such problem on passing the function parameter is a common scenario in functional programming. And this problem is also exist in VisualBasic, if we programming in functional programming way. For example, a VisualBasic plot program that running from the CLI input: [CLI API](https://github.com/xieguigang/GCModeller/blame/9471b3cad362bd8e53d9284c08d0c1cb67edc03a/src/GCModeller/CLI_tools/eggHTS/CLI/1.%20Annotations.vb#L311) -> and then [Data Model API](https://github.com/xieguigang/GCModeller/blame/9471b3cad362bd8e53d9284c08d0c1cb67edc03a/src/GCModeller/annotations/GO/CatalogPlots.vb#L265) -> and then [Common Interface](https://github.com/xieguigang/GCModeller/blame/8c181eb0337af06d7cde7500b6804bc35466c5a0/src/GCModeller/visualize/GCModeller.DataVisualization/CatalogProfiling/CatalogProfiling.vb#L121) -> and finally [reach the Data view's core API](https://github.com/xieguigang/GCModeller/blame/8c181eb0337af06d7cde7500b6804bc35466c5a0/src/GCModeller/visualize/GCModeller.DataVisualization/CatalogProfiling/CatalogProfiling.vb#L153), generates the image plot output like:

[](https://github.com/xieguigang/sciBASIC/blob/f3fa4cdd3ff5de9f6d77a23f8d6ac5989b15d0ec/Data_science/Mathematica/Plot/Plots-statistics/ZScores.vb)
[](https://github.com/xieguigang/sciBASIC/tree/f3fa4cdd3ff5de9f6d77a23f8d6ac5989b15d0ec/Data_science/Mathematica/images/stat)
**Passing such huge number of the function parameter from top stack to the most internal stack would be a terrible nightmare.**
There is a kind of function argument type: ``...`` argument list in R language to help people solving this problems in functional programming way, which is similar to the ``ParamArray`` feature in VB. It works in the way like:
```R
internal = function(a,b,c,d) a+b+c+d
caller = function(x, ...) x * internal(...)
# function calls:
caller(x = 1, a =1, b= 1, c=1, d=1)
```
This argument list makes we passing the function parameter between the function stacks in a super easy way and very handy. I try to using the operator overloads feature to modify the original VB.NET language syntax for implements such argument list feature, it success and works, but still not so naturally and handy.

## Proposal argument List
One possible solution for implement this ``...`` argument feature in native VB language, is using the ``Dictionary(String, Object)`` type. In my opinion, then ``ParamArray`` feature can no limited to the ``Array`` type, and also can applied on the ``KeyValuePair(Of String, Object)`` array, which can generate the ``Dictionary(Of String, Object)``. The key string in the keyvalue pair records the parameter name and the value field that can records the corresponding parameter value.
So that the ``...`` argument list in R language that implements in VB can be something like:
```vbnet
Function Foo(a#, b#)
Return a + b * 2
End Function
Function Caller(x#, ParamArray argumentList As Dictionary(Of String, Object))
' although the function ``Foo`` have two parameter, but the argumentList can adapt to
' such difference by using the dictionary key lookup: by scaning the parameter
' name and compare with the keys in the dictionary to match the right parameter value.
Return x * Foo(argumentList)
End Function
foo(1, 3)
' x is the parameter of function caller,
' a,b is not the parameter of function caller, but the function caller declare a ParamArray Dictionary,
' so that these two additional parameter will construct a Dictionary(Of String, Object) as
' the argument list for the internal calls.
caller(x := 2, a := 1, b := 3)
Function TopCaller(times%, ParamArray argumentList As Dictionary(Of String, Object))
' although the function ``Caller`` have two parameters, and one is double type and another
' is parameter list, but the argumentList can adapt to such difference by using
' dictionary key lookup to match the parameter x, and also passing it self to the
' argumentList in function caller and passing itself to next stack.
Return Replicate(Caller(argumentList), times)
End Function
topcaller(times:= 5, x:=2, a:= 1, b:=3)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.