Hi Alexey!
You are right in all your assumptions :)
In the current version of MetaModelica:
- checking of a statement:
x := matchcontinue (vars) ...
only looks at the type and the
number of input/output variables
- matchcontinue equation sections contain:
+ actual assignments (everything besides equality(x = y)
and pattern matching)
+ equality(x = y) will structurally check for equality
(this is the closest to an equation)
+ pattern match for decomposition:
CONSTRUCTOR(x, y) = var;
CONSTRUCTOR(x, y) = Fcall(vars);
x::y = var;
will bind x and y to subtrees.
+ value construction (the inverse of patterns):
var = CONSTRUCTOR(x, y);
var = x::y;
will bind var to the constructed value.
+ in the case(...) context the constructors
will decompose trees and in the then ...;
context will compose them.
We might change this in the future by adding:
+ additional checks for matchcontinue
+ additional semantics and features for equations
in matchcontinue
Cheers,
Adrian Pop/
[EMAIL PROTECTED] wrote:
Hello!
I have some questions about matchcontinue structure in MetaModelica and
its usage in OMC.
1. The function Builtin.initialEnv begins as follows:
input Env.Cache inCache;
...................................
Env.Cache cache;
algorithm
env := matchcontinue(cache)
I.e., the argument of matchcontinue is a local variable, and the only
input variable inCache is not used anywhere in the function.
Similarly, the first argument of matchcontinue in the function
Inst.instvar is an output variable outCache.
Do I understand correctly that when mmc meets "matchcontinue" in a
function algorithm, it does not really read its arguments and assumes
them to be the input variables (arguments) of the function in the same
order as they are declared?
2. It is said in OpenModelicaMetaProgramming.pdf that equalities in
equation sections of matchcontinue are treated as equations, not as
assignments. So, as far as I understand, equality a=F(a,b), where a,b are
local variables and F is a function without side effects, results in the
following behavior:
the values of a and b are found from earlier equations and/or case
pattern matching (like "case (a,...)");
the function F is called with these values as arguments;
if the result of F coincides with the value of a, nothing happens;
otherwise the case fails.
But sometimes I meet equalities like this in OMC with comments that imply
that these are assignments. For example, in Inst.instClassdef:
//Add connection crefs from equations to connection sets
csets = addConnectionCrefs(csets, eqs_1);
csets_filtered = addConnectionCrefs(csets_filtered, eqs_1);
In Inst.instElement:
(cache,m) = removeSelfModReference(cache,n,m); // Remove self-reference
i.e. A a(x=a.y);
So are these equalities equations or assignments?
Thanks for the help!
Alexey