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
Is assignment of a derived record instance to a base record instance allowed? #1245
Comments
Comment by jmattsson on 15 Aug 2013 09:24 UTC
|
Comment by hansolsson on 4 Sep 2013 12:07 UTC
I agree, but a minor clarification: |
Comment by volker.beuter on 13 Nov 2013 20:50 UTC function F
input R r;
output R0 r0;
algorithm
r0 := r;
end F; i.e. with record input and output, not {{{Real}} ones. |
Comment by stefanv on 13 Nov 2013 20:53 UTC |
Comment by sjoelund.se on 4 Apr 2014 08:02 UTC
There are also some user libraries out there that do precisely the |
Comment by jmattsson on 4 Apr 2014 08:18 UTC Note that there is a very simple work-around for the user in the case Martin brought up: r0.d_hyd := r.d_hyd;
r0.delta := r.delta;
r0.K := r.K;
r0.R_0 := r.R_0; One possible solution would be to not require the elements to be in the same order, and in the external function case just use the order of the declared type in the C struct. I'm not sure what the spec says on that, but I don't see any problems with it. |
Comment by sjoelund.se on 4 Apr 2014 08:33 UTC Spec says
Nothing about type compatibility of records... And since you need to strip out arrays, etc from external structs anyway it is probably fine to allow a different declaration order and still be type compatible. (I also seem to recall some Modelica libraries structuring their records to all be in lexical order for external functions and records to work correctly in all tools. I guess because the structs would be compatible and just a copy instead of a shuffle...) |
Comment by jmattsson on 4 Apr 2014 09:59 UTC
Sure - not saying we should use that workaround, jut that it was there and (conceptually) simple.
I wasn't sure what the spec required and didn't go dig, but that is what I would prefer anyway - so from my standpoint no fix is needed on that.
I recall seeing a support case where a customer had trouble with a specific tool reordering the members of the structs in lexical order before generating C structs for them. It doesn't do that since quite a versions ago, and I haven't heard of any other tools doing that, so I suspect that is simply a legacy practice. Please note that the discussion about same order or not comes from just the parenthesis in my first comment, that even starts with "I think". Well, it seems I thought wrong about that. It seems pretty clear now that they do not have to be in the same order, and that it is a tool issue to convert to the correct struct when needed. Is there any opposition to the interpretation that the records involved in an assignment have to contain the same set of members (i.e. same names and compatible types)? |
Comment by sjoelund.se on 4 Apr 2014 10:32 UTC
|
Comment by jmattsson on 4 Apr 2014 10:55 UTC |
Comment by adrpo on 8 Apr 2014 05:47 UTC |
Comment by dietmarw on 8 Apr 2014 06:40 UTC |
Comment by adrpo on 8 Apr 2014 06:42 UTC |
Comment by jmattsson on 15 Apr 2014 11:45 UTC |
Comment by jmattsson on 20 May 2014 07:35 UTC This fixes this issue for Spice3 - Fluid is still remaining. The problem in Spice3 looked like a simple copy-paste error, and the functions in question are only called in one place. |
Comment by sjoelund.se on 17 Jun 2014 16:33 UTC |
Comment by wischhusen on 20 Jun 2014 11:44 UTC
for functions Channel.kc_evenGapOverall_KC, StraightPipe.kc_overall_KC, StraightPipe.dp_overall_DP, StraightPipe.dp_overall_MFLOW. I could not find an issue with edged and curved bends. Martin S. could you please revert on this issue if it still prevails? |
Comment by sjoelund.se on 20 Jun 2014 20:12 UTC |
Modified by wischhusen on 23 Jun 2014 15:37 UTC |
Changelog modified by wischhusen on 23 Jun 2014 15:37 UTC |
Comment by jmattsson on 14 Jul 2014 07:36 UTC |
Is it correct that this issue with |
I guess you are right here. The invalid assignments are:
@bilderbuchi Could you please open a new issue, referencing this old issue, such that we do not need to reopen this issue. Thanks. |
Sure: #4102. |
Reported by stefanv on 14 Aug 2013 16:48 UTC
Is the assignment in function
F
below allowed, such that onlyr.x
andr.y
are copied intor0
:Migrated-From: https://trac.modelica.org/Modelica/ticket/1245
The text was updated successfully, but these errors were encountered: