-
Notifications
You must be signed in to change notification settings - Fork 55
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
Need clarification on Table constraint type & Table constructor #502
Comments
There are three expressions for the members:
The static types of those expressions are determined as specified by the mapping constructor section of the spec:
You get the smallest record type by unioning the types of the members, and making the fields that are not always present be optional, giving
as you correctly deduced. As for your question 2, if a table has an inherent type that is |
Thanks James for the prompt reply.. |
@jclark , there is a followup question on this. I appreciate, your input on this. var tabObj = table key(id) []; As per the current grammar, the above syntax is possible. Then what is the member of the table? record {| int id; |} or do you have any other suggestions? |
I would either make this a compile-time error, or infer a type of
since there is no information that indicates a more restrictive type than this. |
The spec should say something about this. |
I have mixed opinions on both options. var tabObj = table []; member type needs to be something like below, record { // NB: open
}; Providing a compile error might be a simple and good solution. Then, we could simply mention that mapping constructor exprs are a must to infer the member type. |
I am fine with a compile error. If it turns out to be a problem, we can always relax the constraint. |
Should the spec say something about this? |
@pcnfernando If there's something that's still not clear in the spec after 65074f9, please open a new issue with an example that the spec is not clear about and link to this issue. |
I am expecting some clarification on the below statement regarding the Table.
"If there is no contextually expected type, then the member type of the inherent type is derived from the static type of the expressions for the members: the member type will be the smallest record type that is a supertype of the static types of all the expressions in the expr-list. "
Another question is, as per the spec table constraint type should be a subtype of map<any|error>. Then, it is possible to have a table as given below.
But, in the spec when we talk about key specifiers and key constraint it is somewhat bound to record fields (i.e, record type).
The text was updated successfully, but these errors were encountered: