catala icon indicating copy to clipboard operation
catala copied to clipboard

Input/context subscopes ?

Open AltGr opened this issue 1 year ago • 0 comments
trafficstars

Now that we have "output subscopes", it is only natural to consider "input subscopes".

What would be the point ?

A case that can be considered is defining an "interface" scope that wraps a computation scope, with default input values. We've encountered this use-case already when writing tests with lors of inputs that mimic an admistrative form, and we don't want to repeat 0 for all empty input in every test.

For that case, we embed the computation scope in a superscope, declare context variables for all the inputs, define their default values, then explicit the subscope call. This requires a manual matching of all superscope inputs to the subscope inputs, which can be quite a lot of boilerplate (which requires updating each time a new input is added)

There may be more usecases...

How

Basically, this would require two things:

  • implicit declaration of input/context variables of the superscope matching the input variables of the subscope (named subscopename.varname ?)
  • the ability to specify this variables with names containing a dot in scope calls. Note that this would probably be output of S with { -- sub.sub_var: 0 } rather than output of S with { -- sub: { -- sub_var:0 } }, which wouldn't work well with contextualisation of the sub vars.

AltGr avatar Apr 05 '24 15:04 AltGr