Bug 580511 - [pivot] TemplateParameter is not a Type, introduce TemplateParameterType
Summary: [pivot] TemplateParameter is not a Type, introduce TemplateParameterType
Status: NEW
Alias: None
Product: OCL
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: OCL Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 509309
  Show dependency tree
 
Reported: 2022-08-04 03:45 EDT by Ed Willink CLA
Modified: 2022-08-24 04:57 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2022-08-04 03:45:55 EDT
Operation declarations have Parameters, and the implementation in the form of an ExpressionInOCL has corresponding ParameterVariables.

Similarly TemplateableElement declarations have a signature with TemplateParameters, but their implementation has bindings that also have TemplateParameter giving the awkward requirement that TemplateParameter is a Type.

Work on Bug 580363 to ensure that localizeSpecializations can use TypeIds consistently highlights that we have

The generalization: Collection<T>()
The partial specialization: Collection<>(Bag.T)
The full specialization: Collection<>(String)

This requires TemplateParameter to be a Type, yet for a specialization, provided we don't lose the declaration point for which there is a hierarhical linear list of template parameters; e.g. C<P>::D<Q>::e<R,S>(....) allowing access to {P,Q,R,S} as template parameter $2. There is no need for Collection<>(Bag.T) to be a different type to Collection<>(Set.T); the simpler specialization Collection<>($0) will do. This is particularly beneficial for LambdaTypes that have many identical usages in iterator bodies for slightly different collections. TypeId-wise each identical usage has an identical TypeId.

If we emulate an operation parameter, we separate concerns and need:

TemplateParameterType that is a Type with a TemplateParameter list index.

TemplateParameter that is a TypedElement with a name, a TemplateParameterType type, and a lowerBound type.
Comment 1 Ed Willink CLA 2022-08-10 06:27:36 EDT
(In reply to Ed Willink from comment #0)
> There is no need for Collection<>(Bag.T) to be a different type to
> Collection<>(Set.T); the simpler specialization Collection<>($0) will do.
>... 
> TemplateParameterType type, and a lowerBound type.

This proves to be pretty painful. There are too many places where normalization to $1 is required or denormalization is required to find the lowerBound.

We seems to be digging a deep hole to avoid fixing an inadequate TypedId computation. The modest savings in the serialized orphanage size do not seem worth the pain.

Bottom line: Is Set<T extends MyX> a different type to Set<T extends MyY>? Yes.
Comment 2 Ed Willink CLA 2022-08-24 04:57:10 EDT
(In reply to Ed Willink from comment #1)
> We seems to be digging a deep hole to avoid fixing an inadequate TypedId
> computation. The modest savings in the serialized orphanage size do not seem
> worth the pain.

Back full circle. Allocation of a (Class)TemplateParameterId is no problem. It is (Operation)TemplateParameterId that is difficult since an OperationId uses a ParametersId that may use an (Operation)TemplateParameterId that uses the OperationId. Normalizing the (Operation)TemplateParameterId broke the circle.

Rather than normalizing all (Operation)TemplateParameterId we can get away with just using a normalized entry in the ParametersId and since ParametersId is used solely for uniqueness, we should never need to denormalize.

---

The problem was a very inadequate SpecializedClass/.../Id and a failure to use the Generalized as part of the TemplateParamterId. Prohibiting variant-template operation overloads ensures that the operation TemplateParameterId is just a name child of its OperationId.

Still need the type distinction.