eclipse-ocl / org.eclipse.ocl

Eclipse Public License 2.0
0 stars 0 forks source link

[pivot] Rationalize TemplateParameterSubstitution / TemplateBinding #2263

Open eclipse-ocl-bot opened 1 week ago

eclipse-ocl-bot commented 1 week ago

| --- | --- | | Bugzilla Link | 580407 | | Status | REOPENED | | Importance | P3 normal | | Reported | Jul 20, 2022 03:12 EDT | | Modified | Jun 10, 2023 04:41 EDT | | Blocks | 509309 | | See also | 578117, 580511, 581860 | | Reporter | Ed Willink |

Description

The current TemplateParameterSubstitution / TemplateBinding design follows UML with a simplification to just Type parameters. Oops Collection is now Collection<T,Boolean,Integer,UnlimitedNatural>, see Bug 578117.

The nested TemplateBinding to persist the hierarchy of Package/Class/Operation template parameters is bloat. Let the bound TemplateParameters be flattened.

The flexibility of TemplateParameterSubstitution to support non-positional bindings is useless. Let the bound values be ordered in accordance with the flattened TemplateParameters.


NB The TemplateParameterSubstitution 'actual' is a Class for the normal Class Parameter case, but may be any value (i.e. Object) for the DataType case.

Consider a BookRole<Book-instance,Collection> for which Book-instance, may be a Book instance, e.g. "St. James Bible" and Collection may be a collection of translations/editions/... what would be the syntax for Book-instance rather than Book?

Surely this is stupid. Simpler to do.

class BookRole {\ property theInstance : Book;\ property derivations : Collection(Book);\ }

But is 'simpler' necessary?

If it is necessary for Class instances, why isn't it necessary for DataType values too?

class MySet {\ property elements : Set(T);\ property nullFree : Boolean;\ property lower: Integer;\ property upper: UnlimitedNatural;\ }

Migrating to Set<T,Boolean,Integer,UnlimitedNatural> seems like a mistake. TemplateParameters can only be bound to Classes in the normalized pivot; the UML binding to a DataType should be normalized as a construction argument.

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Jul 20, 2022 03:49

(In reply to Ed Willink from comment #0)

TemplateParameters can only be bound to Classes in the normalized pivot; the UML binding to a DataType should be normalized as a construction argument.

A Class specialization rewrite is just a matter of assigning the properties with constants for DataTyped values, variables for Class-typed parameters. i.e. DataType-typed parameters are rewitten as Class properties.

An Operation specialization is perhaps just a redirection of an implementation with just Class-typed parameters to an underlying implementation with additional DataTyped constants. i.e. DataType-typed parameters are rewritten as Operation parameters.

?? Package DataType-typed.

?? a TemplateableElement has a constant value for each DataType-typed parameter

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Aug 05, 2022 02:59

Work on Bug 580363 identifies requires LambdaType to have a distinct typeid, which only happens once we erase TemplateParameter to its index. This seems to need general a universal split between TemplateParameter as non-type Parameter and as shared unresolved type; see Bug 580511.

Once shared TemplateParameters with distinct TemplateParameterId are in place, it is clear that WildcardType can be simplified. There is a special handling in TemplateParameterSubstitution.setActual to exploit TemplateParameterSubstitution.ownedWildcard. This can be boringly regular just so long as the local/shared orphanage maintain the wildcard singleton.

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Aug 24, 2022 06:34

(In reply to Ed Willink from comment #2)

This can be boringly regular just so long as the local/shared orphanage maintain the wildcard singleton.

Done and a WildcardId added in place of the magic (not-used) UnspecifiedId.

More generally fixed as part of the Bug 580363 revamp of ASSaver / TemplateParameterId

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Aug 24, 2022 07:27

Pushed to master for 2022-12M1a

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Apr 25, 2023 03:38

(In reply to Ed Willink from comment #3)

Done and a WildcardId added in place of the magic (not-used) UnspecifiedId.

No. See Bug 581860. wilcards are template parameters not a type singleton.

eclipse-ocl-bot commented 1 week ago

By Ed Willink on Jun 10, 2023 04:41

Not fixed. Progress on Wildcards, value templateParamters does not chnage the main issue that TemplateParamtrerSubstitution is bloat.

Branch ewillink/580407 demonstrates that we can promote\ TemplateableElement.ownedSignature.ownedParamters to\ TemplateableElement.ownedTemplateParamters\ TemplateableElement.ownedBindings.ownedSubstitutions.actual to\ TemplateableElement.templateArguments\ TemplateSignature, TemplateBinding, TemplateParamterSubstitution are obsolete

New derived TemplateableElement.allTemplateParamters aggregates the ancestors to provide positional equivalence to the TemplateableElement.ownedBindings.ownedSubstitutions.formal

It all works until dead model elements are actually pruned. It seems that some of the auto-gen is using old FeatureId inconsistently. Hopefully fixed as part of the Pivot+OCLstdlib merge.