apigear-io / cli

The ApiGear client as go project
https://apigear.io
MIT License
1 stars 2 forks source link

inputs and outputs #130

Closed jryannel closed 2 months ago

jryannel commented 6 months ago

Currently we see functions as a set of parameters and one single return value. Here we suggest to have a set of input value and a set of output values for a function. E.g.

function(a: int, b: int) (c: int, d: int)

In c++ this would be:

function(int a, int b, c& int, d& int)

The value allocation is then on the caller side.

In the YAML spec the inputs and outputs will replace the params and return declaration.

operations:
  - name: add
    inputs:
      - name: a
        type: int
      - name: b
        type: int
    outputs:
      - name: c
        type: int

will declare a c++ func as:

void add(int a, int b, int *c)

When called, the output parameter is stack-allocated and initialised with default value.

int c = 0;
add(10, 20, &c)

For go this would look like this:

var c int;
add(10, 10, &c)

This should also make the serialisation simpler as we always handle named vars, which can be encapsulated into a struct.

jryannel commented 2 months ago

We will not implement this. Major rework, no real benefits