Define that package.order requires a package - #3928
Conversation
…should be stored as package.mo.
I can see that it would be an inconsistency to allow package.mo for a class where it is not allowed to have a corresponding package.order. However, I think there are good use cases also for storing non-packages in a directory with one or more .mo files inside:
Edit: @maltelenz just pointed out that https://specification.modelica.org/master/packages.html#external-resources speaks of package name, so I am striking out the item about regarding external resources attached to non-packages. |
| In order to preserve the order of classes and constants, it is advisable to create a file \filename{package.order}\index{package.order@\filename{package.order}} where each line contains the name of one class or constant (using its Modelica \lstinline!IDENT! form). | ||
| If a \filename{package.order} is present when reading a directory, the classes and constants are added in this order; if the contents does not exactly match the classes and constants in the package, the resulting order is tool specific and a warning may be given. | ||
| In order to preserve the order of classes and constants in package, it is advisable to create a file \filename{package.order}\index{package.order@\filename{package.order}} where each line contains the name of one class or constant (using its Modelica \lstinline!IDENT! form). | ||
| If a \filename{package.order} is present when reading a directory for a package, the classes and constants are added in this order; if the contents does not exactly match the classes and constants in the package, the resulting order is tool specific and a warning may be given. |
There was a problem hiding this comment.
Don't we want to be more restrictive and actually ban the presence of package.order for non-packages?
There was a problem hiding this comment.
If we allow a directory structure for non package classes, probably also a package.order file is needed for that.
There was a problem hiding this comment.
The current support for package constants is of course easy to generalize to non-constant components, but the whole point of this PR is that the package.order idea is too difficult to apply to classes with equations.
There was a problem hiding this comment.
To me the relevant case other case is storing a top-level non-package in package.mo to have the Resources-directory as though it were a package; so we only want the directory structure for the Resources-directory not for storing local classes.
I would even say that there is no need to store any potential sub-classes separately for that case, and it's even a bit unusual to have a non-short local class inside a model; and if it is a short class it cannot be stored in a separate file.
There was a problem hiding this comment.
To me the relevant case other case is storing a top-level non-package in package.mo to have the Resources-directory as though it were a package; so we only want the directory structure for the Resources-directory not for storing local classes.
This relates to the item I stroke out in #3928 (comment) above since the external resource text very clearly speaks of packages, not classes defined in a package.mo. I this something we should revisit as part of this PR?
There was a problem hiding this comment.
Yes, I'll add the minimal part.
henrikt-ma
left a comment
There was a problem hiding this comment.
More discussion is needed regarding the status of package.mo for non-packages.
Co-authored-by: Malte Lenz <malte@maltelenz.se>
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
Co-authored-by: Henrik Tidefelt <henrikt@wolfram.com>
|
Language meeting: Goal:
Agreement?: Most in favor, but Gerd thinks that package.order could work; so allow Off-line poll->Hans |
|
Background:
Poll for variants among MAP-Lang members:
Select one (or possibly more) reaction(s) from "Add or Remove Reaction" (below to the left). |
|
The poll above does not include the following liberal and backward compatible alternative discussed at the meeting:
|
I must have missed that idea, but added it. However, note that:
|
|
With ❤️ and 🚀, imagine that However, the same pattern doesn't work when an FMU is imported as a top-level class, because then the directory corresponding to, say, FMU_A would be the top-level directory of the package, meaning that FMU_A.mo will sitt side by with with Resources: Hence, it gets a bit messy to move an imported FMU from the original top-level location into a package like With 🎉 and 👀, the same pattern can be used both at the top-level and inside packages. Top-level: Inside package: |
|
Was there a misunderstanding of "Storing sub-classes in separate files and/or directories (together with package.mo) is only allowed for packages."? The parenthesis can be skipped and the idea was:
Added: I know that there were a discussion on restricting non-package |
Don't know if anybody misunderstood, but skipping it sounds like a good idea.
I think the imported FMU example shows clearly that it can be a good idea. |
and that only packages should be stored as package.mo.
Closes #3921
Note: I generalized it to require that even package.mo should (so, there might be exceptions) be a package. We might revisit that, but I think it is a good general rule.
I agree that having package.order for a non-package would be really problematic - as there are non-constants, equations etc that must be ordered.
Having package.mo for a non-package would to me only make sense for a top-level class where you want to store resources as if it were a package, and in that case having sub-classes (and especially sub-classes stored externally) doesn't really make sense.