How can function argument declaration be introspected?

Is there a way to programmatically access the function argument validation declared in the argument block? meta.method introspection only allows to determine argument names, but I am interested in all of the validation features (dimensions, class, validation functions).
My need especially focuses on functions (not only class methods) and also on output arguments.

3 comentarios

Kati
Kati el 29 de Sept. de 2022
Hi Simon, I work with the team who works on the arguments blocks and meta information. We'd like to hear more about what you're wanting to do with the meta information. Could you please send me a message via the link on my profile?
Sean
Sean el 8 de Ag. de 2024
This is an old question with no answers. So I assume there was no way to do this back in 2022. Has there been any changes? I am also very interested in doing this.
Umar
Umar el 8 de Ag. de 2024
Editada: Walter Roberson el 8 de Ag. de 2024
Hi @Simon Sigl,
As I am aware of argument validation enhances code readability and maintainability by enforcing specific input and output requirements. However, traditional introspection methods, such as `meta.method`, only reveal argument names without detailing the associated validation criteria (e.g., size, class). I doubt that if there is no built-in method for programmatically accessing full argument validation details declared in the `arguments` block. Also, the`meta.method` class provides some metadata but does not extend to validation features. I would suggest implementing a mechanism within your functions to document validations explicitly using structured data.Use documentation comments to describe validations, enhancing code readability. Explore `meta.class` along with `meta.method` for structured understanding of class methods. Please bear in mind that Output arguments can also be validated, but similar strategies apply for introspection.
Here are some useful links that will help your aid in your research.
In nutshell, while direct programmatic access to detailed argument validations in MATLAB is currently limited, utilizing custom structures and thorough documentation can effectively address these challenges. Future updates may further improve these capabilities.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Class Introspection and Metadata en Centro de ayuda y File Exchange.

Productos

Versión

R2022b

Preguntada:

el 29 de Sept. de 2022

Editada:

el 8 de Ag. de 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by