-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default values for function input variables #1346
Comments
Comment by stefanv on 8 Nov 2013 18:36 UTC |
Comment by sjoelund.se on 8 Nov 2013 18:43 UTC function G
input Real x;
input Real y = 2*z;
output Real o;
protected
Real z = x;
algorithm
o := x + y + z;
end G; |
Comment by stefanv on 8 Nov 2013 20:40 UTC |
Comment by perost on 8 Nov 2013 22:53 UTC
So the behaviour seems well-defined for everything that's not inputs. It seems to me like it would be reasonable to also include inputs with default values in this sorting. |
Comment by hansolsson on 4 Dec 2013 11:07 UTC For each function call the default values are evaluated in an order such that the input is not used before its declaration assignment has been executed, it is an error if no such order exists (i.e. the bindings must be acyclic). Unclear: Is there still any functions in MSL not satisfying the first paragraph? |
Comment by stefanv on 4 Dec 2013 11:21 UTC model M
constant Real K = 1;
function F
parameter Real P = 2;
input Real x = K + P;
output Real y;
algorithm
y := x^2;
end F;
end M; Note that this allows one to generate different versions of functions for different applications: model M2 = M(F.P=3); |
Comment by hansolsson on 14 Mar 2014 14:14 UTC
Substitute until nothing left (acyclic dependencies). Favor: 6 |
Comment by hansolsson on 14 Mar 2014 14:25 UTC
Sven Erik: Hard to understand - should be able to understand interface of foo - without looking at internals. Solution: Only allow input-defaults to depend on inputs. Input defaults depending on inputs exist in MSL - e.g. Modelica.Math.Matrices.continuousLyapunov |
Modified by hansolsson on 22 Mar 2014 10:25 UTC |
Comment by hansolsson on 22 Mar 2014 10:25 UTC |
Reported by stefanv on 8 Nov 2013 18:35 UTC
Is the default value of a function input variable allowed to be an expression referring to other input variables? Like this:
I would of course say yes. But can the default value of a function's input variable depend on a later input variable? Like this:
Migrated-From: https://trac.modelica.org/Modelica/ticket/1346
The text was updated successfully, but these errors were encountered: