[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [OASIS Issue Tracker] Commented: (ODATA-395) Simplify rule for implicit values of enumeration members
[ http://tools.oasis-open.org/issues/browse/ODATA-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33454#action_33454 ]
Stefan Drees commented on ODATA-395:
------------------------------------
So as runnable c++ code:
#include <iostream>
enum ShippingMethod {
VIP,
FirstClass,
TwoDay = 0,
Overnight
};
int main()
{
ShippingMethod shipMe = TwoDay;
std::cout << " VIP = " << VIP << ", FirstClass = "
<< FirstClass << ", TwoDay = " << shipMe
<< ", and Overnight = " << Overnight << '\n';
}
the execution should yield:
VIP = 0, FirstClass = 1, TwoDay = 0, and Overnight = 1
and does so.
Although I might already be included inside the "we" of the descriptions four-valued last sentence ;-) why not stating it explicitly:
I second the proposal even in c/c++ code I personally consider it good style to either let the compiler decide on or to explicitly set all values.
The latter is triggered quite often, when interfacing to pre-existing sets of constants (where gaps are present).
> Simplify rule for implicit values of enumeration members
> --------------------------------------------------------
>
> Key: ODATA-395
> URL: http://tools.oasis-open.org/issues/browse/ODATA-395
> Project: OASIS Open Data Protocol (OData) TC
> Issue Type: Improvement
> Components: OData CSDL
> Affects Versions: V4.0_CSD01
> Environment: [Proposed]
> Reporter: Ralf Handl
> Fix For: V4.0_CSD02
>
>
> Enumeration members have an optional Value attribute for specifying an integer equivalent to the symbolic member name that is for ordering.
> The current rule for implicitly numbering the enumeration members is cloned from the C family of programming languages and allows specifying values for some members while having the other members being numbered implicitly. This can lead to surprising results for the uninitiated:
> <EnumType Name="ShippingMethod">
> <Member Name="VIP"/>
> <Member Name="FirstClass"/>
> <Member Name="TwoDay" Value="0"/>
> <Member Name="Overnight"/>
> </EnumType>
> The result is that both VIP and TwoDay get the value zero and both FirstClass and Overnight get the value 1.
> While we see value in having Value optional, we see no value in providing a value for some members only.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://tools.oasis-open.org/issues/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]