Question regarding type-coercion-constraints #9179
Replies: 1 comment
-
|
The reason we need this constraint is to simply the standard library definition of vectors, such that we can define a single Type coercion currently has more rules than just look for existence of an implicit |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a question regarding the desired implementation for type-coercion-constraints (
TypeCoercionConstraintDecland related).From what I understand, there are a few potential approaches to implement this constraint (that comes to mind for me), but I am not exactly sure on the original intent for this feature:
TypeCoercionConstraintDecla wrapper for aGenericTypeConstraintDeclwith the super-type of (a new magic type called)CoerceTo<T>. Existing machinery will handle the rest of the logic.CoerceTo<T>look like?interface CoerceTo<T> { __init(T arg); }CoerceTo<T>) to allstructs with a type__init(T arg). Then when building ourInheritanceInfoviagetInheritanceInfowe would only need to insert aFacetforCoerceTo<T>if we find aTypeCoercionConstraintDeclin ourgetDependentGenericParent. Existing machinery will handle the rest of the logic.TypeCoercionConstraintDeclis a new type of constraint that effectively just checks for a members presence.where T __contains_member getFuncTypeAndName<TR, each TP>(String nameOfFunction)where T __contains_member getFuncTypeAndName<T>("__init")Beta Was this translation helpful? Give feedback.
All reactions