-
Notifications
You must be signed in to change notification settings - Fork 34
ST6RI-818 Constructor expressions (KERML_-132/222, SYSML2_-766) #638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Removed this from FunctionAdapter and ExpressionAdapter. - Added it back just in FeatureReferenceExpressionAdapter and InvocationExpressionAdapter.
- Derivations and operations for invocation and constructor expressions. - instantiatedType operation for operator and trigger invocation expressions.
validateFeatureReferenceResult validateConstructorExpressionNoDuplicateFeatureRedfinition validateConstructorExpressionOwnedFeatures validateInstantiationExpressionInstantiatedType validateInstantiationExpressionResult validateInvocationExpressionInstantiatedType validateInvocationExpressionNoDuplicateParameterRedefinition (updated) validateInvocationExpressionOwnedFeatures validateInvocationExpressionParameterRedefinition (updated)
I am reviewing this. I could not find any issues so far. But I found ConstructorExpression can be used for behavior as well as InvocationExpression. For example,
Are these expressions having the same semantics? P.S. |
Yes, this is mentioned in the PR description:
|
sysml.library/Kernel Libraries/Kernel Function Library/BaseFunctions.kerml
Show resolved
Hide resolved
👍 Good for merge. I did not find any overlooked constructor expresssions that need a |
sysml/src/validation/05-State-based Behavior/5-State-based Behavior-1.sysml
Show resolved
Hide resolved
sysml/src/validation/05-State-based Behavior/5-State-based Behavior-1a.sysml
Show resolved
Hide resolved
Ed, thank you for your answer. I found a bit strange behavior of the validation. In KerML, the number of parameter could be checked:
This causes an error of `Bound features should have conforming types". However, in SysML, it does not seem to be checked:
Am I missing something? I found the parameter types are correctly checked. So |
I believe this is correct per the approved specification, but it is not particularly intuitive, so it is something we might want to address in the RTF. What is happening here is actually not a check on the number of parameters. Rather, the class In the case of |
Ed, thank you for the detailed explanation. I confirmed if I change |
- Updated TypeAdapter::getFeaturesRedefinedByType to add additional members before getting redefined features.
This PR implements resolutions to the following issues, as approved in KerML FTF2 Ballots #5 and #6 and SysML v2 FTF 2 Ballot #8:
Previously, an invocation expression where the invoked type was not a function acted as a constructor for an instance of the invoked type. The resulting usage was both typed by the invoked type and a subset of
Performances::evaluations
. But, if the invoked type was a data type or structure, then this was a semantic inconsistency, becausePerformance
(a supertype ofevaluations
) is disjoint withDataValue
andObject
. The resolution to KERML_-132 fixes this by introducing a new kind of constructor expression and requiring that the invoked type of an invocation expression be a behavior or function.Abstract Syntax
InstantiationExpression
InvocationExpression
andConstructorExpression
.instantiatedType
, which is theType
invoked/instantiated by the expression.instantiatedType
of any kind ofInstantiationExpression
, other than anOperatorExpression
orTriggerInvocationExpression
(in SysML), is parsed as a member of the expression. (There are special derivation rules for theinstantiatedType
of anOperatorExpression
orTriggerInvocationExpression
.)InstantiationExpression
must own itsresult
parameter.InvocationExpression
InvocationExpression
is required to specialize theinstantiatedType
, as before.instantiatedType
of anInvocationExpression
must be aBehavior
, normally aFunction
.instantiatedType
is aBehavior
that is not aFunction
, then theInvocationExpression
is still typed by theBehavior
, with itsresult
bound to the expression itself. This allows non-Function
Behaviors
to still be essentially "constructed" using anInvocationExpression
, as before. (This does not cause semantic problems, because it is acceptable to specialize aPerformance
of theBehavior
to anEvaluation
that returns itself.)arguments
of anInvocationExpression
are parsed asFeatureValues
ofownedFeatures
of the expression itself, as before.ConstructorExpression
InvocationExpressions
with constructor semantics.ConstructorExpression
is required to specialize theinstantiatedType
.arguments
of aConstructorExpression
are parsed asFeatureValues
ofownedFeatures
of theresult
of theConstructorExpression
. (In this way, a value of theinstantiatedType
is "constructed" as theresult
of theConstructorExpression
, while the expression itself can still be typed as anEvaluation
.)FeatureReferenceExpression
FeatureReferenceExpression
is also updated with a new validation constraint requiring that it own itsresult
parameter.Note. The Pilot Implementation previously inserted an owned
result
parameter for all kinds of expressions. Now this is only done forInstantiationExpressions
andFeatureReferenceExpressions
.Concrete Syntax
The concrete syntax for a constructor expression is similar to that of an invocation expression, but preceded by the keyword
new
.Model Libraries
Kernel Semantic Library
Performances
– AddconstructorEvaluations
as the base feature of allConstructorExpressions
.constructorEvaluations
is a specialization ofevaluations
that restricts the multiplicity of itsresult
parameter to1..1
, requiring aconstructorEvaluation
to result in a single value.Triggers
– Use the new syntax to construct the result values forTriggerWhen
andTriggerAt
.SysML Domain Libraries
SampleFunctions
– Use the new syntax to construct the result value for the calculation definitionSample
.RiskMetadata
– Use the new syntax to construct the enumerated values of the enumeration definitionRiskLevel
.MeasurementReferences
– Use the new syntax to construct the value of the attribute usageone
.