CDM function's parameter type cardinality not being checked? #3422
-
Support QuestionI have come across couple of cases in CDM Rosetta function calls where the cardinality of the target function arguments appears to be ignored. For example, there are cases where a function declared to accept a value of type with cardinality [1..1], can be called with a constant [ ] or a value declared as [0..1]. Seems odd that when the function expects 1 and only 1 value, Rosetta allows it being called with no value. Is that accepted for CDM/DRR? I'd imagine that could lead to some inconsistent behaviour. Could someone please clarify? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, I will move this to a Discussion / Q&A and close this issue |
Beta Was this translation helpful? Give feedback.
-
Hi @ghost, I know this is an old question, but just to come back to this. There is actually a good reason why these cardinality checks are loose. Just to illustrate, consider the following function that takes a required argument.
As you have noted correctly, this function can also be called with an optional value, e.g., given an optional attribute
we can still call
This expression will only call the function if Of course, one could argue that Rosetta should be smarter and figure out if a check was performed, in this context the actual constraint of This was one of the subjects of my master thesis - the conclusion is that it it definitely possible theoretically, but quite an investment to get right. :) |
Beta Was this translation helpful? Give feedback.
Hi @ghost, I know this is an old question, but just to come back to this. There is actually a good reason why these cardinality checks are loose.
Just to illustrate, consider the following function that takes a required argument.
As you have noted correctly, this function can also be called with an optional value, e.g., given an optional attribute
we can still call
RequiredArgumentFunction(optional)
without any errors. Suppose that we would forbid this, then consider another expression: