-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or requestsubject: code generationThis issue is about code generationThis issue is about code generationsubject: model validationThis issue is about validation of Rosetta models, such as the type systemThis issue is about validation of Rosetta models, such as the type systemsubject: syntaxThis issue is about the syntax of RosettaThis issue is about the syntax of Rosetta
Description
See parent issue: #1077
Typically, a translation consists of many transitive function calls, e.g.,
MapDocument -> MapTradeInformation -> MapProduct -> MapSecurityLendingGiven the extension ExtendedTradeInformation which adds a default currency, suppose we need to access this property when mapping a SecurityLending. Since, when overriding functions, we cannot add additional parameters, we need a different way to communicate this new property from MapTradeInformation down to MapSecurityLending.
To achieve this, we introduce the concept of a context.
scope MyScope
type MyContext:
defaultCurrency DefaultCurrency (1..1)
func ExtendedMapTradeInformation overrides MapTradeInformation:
inputs:
tradeInformation TradeInformation (1..1)
output:
result Trade (1..1)
context:
context MyContext (1..1)
set context -> defaultCurrency: (tradeInformation as ExtendedTradeInformation) -> defaultCurrency
set result: proceed(tradeInformation)
func ExtendedMapSecurityLending overrides MapSecurityLending:
inputs:
securityLending SecurityLending (1..1)
output:
result Foo (1..1)
context:
context MyContext (1..1)
set result: proceed(tradeInformation)
set result -> currency: result -> currency default context -> defaultCurrencyIn the above example, three important concepts are illustrated.
- We declare that a function is using a context with a new section below the output of the function:
context: context MyContext (1..1). - In
ExtendedMapTradeInformation, we set a property in the context usingset context -> defaultCurrency: ..., similar to how we set the output of a function. - In
ExtendedMapSecurityLending, we access a property from the context usingcontext -> defaultCurrency, similar to how we access the input of a function.
In order for functions to stay stateless, any changes to a context are discarded right after the end of a function call.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestsubject: code generationThis issue is about code generationThis issue is about code generationsubject: model validationThis issue is about validation of Rosetta models, such as the type systemThis issue is about validation of Rosetta models, such as the type systemsubject: syntaxThis issue is about the syntax of RosettaThis issue is about the syntax of Rosetta