Dynamic superclass name in call to superclass method.
조회 수: 4(최근 30일)
but back then the only option seemed to involve the evil eval:
eval( ['methodName@', superclassName, '(args..)'] ) ;
Do you know if MATLAB implements a better mechanism now?
To give a little more information about the context, I am working on a framework that involves e.g. the following classes:
Project < ProjectKernel < Resource < ResourceKernel < Core < handle
each of which implements an errorManager method that produces extended error analysis/reporting. Now say the Core implements a method/validator for setting a user level : Core.set.userLevelId. If I try to set an invalid user level in a project object:
project = Project() ;
project.userLevelId = -1 ;
the error management mechanism makes Project.errorManager capture the error, which must delegate the creation of the error report to Core.errorManager (because each class implements the management of errors associated with its own specific features/resources). The class name Core can easily be extracted from dbstack, but right now it seems that the only way to call errorManager@Core(...) is by using the approach based on eval.
Of course, it would be more satisfactory to use nested try/catch statements and to filter/rethrow based on the identifier, but we are not in such a context with the hierarchy of classes.