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 件のコメント
Kati
2022 年 9 月 29 日
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
2024 年 8 月 8 日
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
2024 年 8 月 8 日
編集済み: Walter Roberson
2024 年 8 月 8 日
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.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Class Introspection and Metadata についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!