Limited support for child discovery for custom dot-indexing classes #34
Labels
No labels
bug
duplicate
enhancement/documentation
enhancement/feature
enhancement/organization
question
rejected
upstream
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
UserCurt/mpath#34
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Classes can override
properties, which can affect MPath child-discovery behavior. For example, thestringclass overrides thepropertiesto have completely different semantics, not for listing properties (child discovery).Relatedly, some classes can support dot access for names that are not discoverable through
properties. This can happen when overridingmatlab.mixin.indexing.RedefinesDotbecause it does not require exposing valid children names throughproperties. MPath could also usemetaclass(target).PropertyListas a child discovery mechanism, but only for class-defined properties (after filtering those that are publicly accessible and visible). It will not work with dynamic properties, an dit will not reflect valid dot operations when overloaded viamatlab.mixin.indexing.RedefinesDot.MPath currently relies on child-name discovery for data-derived dot matching (e.g., in
DotGlob) and future discovery-based features such as filtering (#33). Classes with non-discoverable children would have limited support in MPath. This is a known limitation without a known solution.This is not an issue with
DotExactorDotSetbecause matching is user-supplied rather than data-derived. The system does not need to validate paths by checking if children exist directly. Instead, the atomic chunk planner guardslistLength(...)with a try-catch; if an exception is caught, it is assumed that the operation chain is not valid. This was necessary because MATLAB does not provide a standardized way viamatlab.mixin.indexing.RedefinesDotto query whether a chain of indexing operations is valid for the given class instance without just trying it.This issue is left for ideas on how to address this issue.
To address the lack of discoverability of children, MPath could have it's own mixin requiring a method that custom classes can implement or look for a a special method with a particular name like
mpathMemberNames, which would return the list of children. This would be similar behaving to:propertiesormetaclass(obj).PropertyListfieldnamesT.Properties.VariableNamesNote that the proposed method should only work for children members that can be accessed through dot indexing, which is different from the children-like way the types below work:
keyskeyscategoriesWorth noting that it is unclear if MPath should support namespaces:
namespaceClasses,namespaceFunctions,innerNamespacesormatlab.metadata.Namespace.fromName(...)Commit
6803cb2documents this known limitation inLIMITATIONS.md.Although
keys, for example, may not be discoverable, it can be still invoked by MPath when user-specified because MATLAB invokes zero-arity(ish) class instance methods when usingdata.(indexOps)dot indexing.