(Enhancement Request) generated code for the "arguments...end" default argument syntax in matlab coder

4 ビュー (過去 30 日間)
It is well known that the 'arguments' default argument syntax is very easy to use and read in MATLAB functions.In the latest version of MATLAB 2022b, C/C++ code generation for "arguments" is now supported, and according to the documentation, the entry-point function default arguments are embedded in hard-coded form.
In such situations, the default values of these optional arguments are hard-coded in the generated code and these arguments do not appear in the generated code interface.
This leads to a usability problem, if I need to make changes to the default argument values in the generated C++ code, I have difficulty in finding the location of the default arguments. Because the generated C++ code is intended for use by third parties, the default parameters should be given some flexibility to allow third party users to modify the default parameter values of the C++ function parameters.
Example:
MATLAB Code for code generation,
codegen -config:lib -c useDefaults_2 -args 0 -report
function out = useDefaults_2(a,b,c)
arguments
a (1,1) double
b (1,1) double = 5
c (1,1) double = 7
end
out = a + b + c;
end
expected:
generate a test.h and test.cpp.
test.h
double useDefaults_2(double a,double b=5,double c=7);
test.cpp
double useDefaults_2(double a,double b,double c)
{
return a+b+c;
}
instead of:
double useDefaults_2(double a)
{
return (a + 5.0) + 7.0;
}
It would be nice if in the future a soft-coded form of embedding for entry function parameters could be provided! This is because it is more in line with the Default arguments form of the C++ language itself, which is intuitive to us and easy to port to be used by others.
  2 件のコメント
John D'Errico
John D'Errico 2023 年 2 月 19 日
Please don't flag an answer as not helpful like that. I removed the flag. Perhaps you think Answers is tecnical support. It is not that. Answers is completely volunteer run. Even the rare user with the tag STAFF on their name is often answering questions by their own choice.
Your question seems to reduce to a suggestion for the software, essentially a feature request, and not a question about MATLAB at all. Steve told you to post enhancement/feature requests to the proper place. That proper place is NOT Answers.
cui,xingxing
cui,xingxing 2023 年 2 月 19 日
Please note I'm just making a flag and that's all, I personally don't see anything wrong on the Q&A community!
Also regarding feature requests/enhancements it's not that I don't want to post them where they fit, it's that they often go unanswered, if I follow your argument I believe most of my questions would be classed as "not MATLAB related" and many of them would tend to be feature requests/enhancements, but in fact many of the answers are positive and in a way contribute to MATLAB's future development is a worthy contribution.

サインインしてコメントする。

採用された回答

Denis Gurchenkov
Denis Gurchenkov 2023 年 9 月 20 日
Hi CUI, just to follow up, yes this is an enhancement that is being considered for a future release. Thanks for your input!

その他の回答 (1 件)

Steven Lord
Steven Lord 2023 年 2 月 14 日
Please send this enhancement request to Technical Support directly using the Contact Support link under the Get Support heading at the end of this page.

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by