catala
catala copied to clipboard
Support for easily carrying variables into a sub-scope
Ideally, I would like things to look like this:
declaration scope Test1:
context taxpayer scope TaxPayer
context return scope TaxReturn
# This kind of mechanism should be limited to those variables of the
# sub-scopes that have been marked as input.
context section108d3 scope Section108d3 with taxpayer, taxreturn
context section61a scope Section108d3 with taxpayer = taxpayer1, taxreturn = taxreturn1
with the syntactic "pun" being allowed only if the names match
this would i) save a tremendous amount of verbosity later on, and ii) set these relationships as being "immutable" (because they're declared in the preamble), which is good, because such links are not intended to be overridden later on with an exception
it would be great to also make sure that this easy replication of variables into a sub-scope is only for those variables marked as inputs (see #112
Thanks,
Jonathan
This should be merged into the discussion for #277: we probably want a similar syntax for calling scopes as subscopes like here, and as function calls like in #277.
Good remark. We could do something like this to declare all the arguments to a sub-scope call at once:
declaration scope Test1:
context taxpayer scope TaxPayer
context return scope TaxReturn
# This kind of mechanism should be limited to those variables of the
# sub-scopes that have been marked as input.
context section108d3 scope Section108d3 with taxpayer, taxreturn
context section61a scope Section108d3 with taxpayer = taxpayer1, taxreturn = taxreturn1
scope Test1:
definition section108d3 of {
-- taxpayer : taxpayer
-- taxreturn: taxreturn
}
definition section61a of {
-- taxpayer : taxpayer1
-- taxreturn: taxreturn1
}
If you define all the arguments at once, can you also redefine them with things like this later on?
scope Test1:
exception definition section61a.taxpayer under condition foo is True equals taxpayer2