OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

odata message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: [OASIS Issue Tracker] Issue Comment Edited: (ODATA-96) Need to define semantics, serialization format, etc. for Enums


    [ http://tools.oasis-open.org/issues/browse/ODATA-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=32070#action_32070 ] 

Ralf Handl edited comment on ODATA-96 at 1/16/13 5:24 AM:
----------------------------------------------------------

Negative values and IFlags="true": do we want to allow this?

The proposal currently defines the combined value to be the sum of the discrete values, while e.g. C# defines the combined value to be the bitwise OR of the discrete values. The latter actually seems more natural. Using the example from the proposal

<EnumType Name="Pattern" UnderlyingType="Edm.Int32" IsFlags="true">
   <Member Name="Red" Value="1"/>
   <Member Name="Blue" Value="2"/>
   <Member Name="Yellow" Value="4"/>
   <Member Name="Solid" Value="8"/>
   <Member Name="Striped" Value="16"/>
   <Member Name="SolidRed" Value="9"/>
   <Member Name="SolidBlue" Value="10"/>
   <Member Name="SolidYellow" Value="12"/>
   <Member Name="RedBlueStriped" Value="19"/>
   <Member Name="RedYellowStriped" Value="21"/>
   <Member Name="BlueYellowStriped" Value="22"/>
</EnumType>

Using the sum of the discrete values Sales.Pattern'Yellow,SolidYellow' would be equal to Sales.Pattern'Striped', which is somewhat surprising.

Using the bitwise OR of the discrete values Sales.Pattern'Yellow,SolidYellow' would be equal to Sales.Pattern'SolidYellow'. This is also what the proposal states in section "Literal Form", and makes interpretation of the function has() feasible.

If we go for the bitwise OR interpretation, we run into problems with negative values because there are several bit representations of negative integers out in the wild.

      was (Author: ralfhandl):
    Negative values and IFlags="true": do we want to allow this?

The proposal defines the combined value to be the sum of the discrete values, while e.g. C# defines the combined value to be the bitwise OR of the discrete values, which will yield the same result only for positive values.

C#:
[Flags]
enum Feel { hungry=-1, satiated=1, undecided=0}
Feel.hungry|Feel.satiated == Feel.hungry

OData:
<EnumType Name="Feel" IsFlags><Member Name="hungry" Value="-1"/><Member Name="satiated" Value="1"/><Member Name="undecided" Value="0"/></EnumType>
Model.Feel'hungry,satiated' eq Model.Feel'undecided'
  
> Need to define semantics, serialization format, etc. for Enums
> --------------------------------------------------------------
>
>                 Key: ODATA-96
>                 URL: http://tools.oasis-open.org/issues/browse/ODATA-96
>             Project: OASIS Open Data Protocol (OData) TC
>          Issue Type: Bug
>          Components: OData ABNF Construction Rules v1.0, OData ATOM Format v1.0, OData JSON Format v1.0, OData Protocol v1.0
>    Affects Versions: WD01
>         Environment: [Proposed]
>            Reporter: Michael Pizzo
>            Assignee: Michael Pizzo
>             Fix For: WD01
>
>
> Enums are allowed in an entity model, but their semantics are not defined. We need to define semantics and serialization for each format. For example:
> -Are they serialized as their underlying type or the enumeration value name (I would propose the later). 
> -How are enumeration values specified in expressions (I propose as name rather than underlying value)
> -How are flags expressed for enumeration values? (I propose defining the use of the pipe (|) character for this purpose in the ABNF)
> -Can multiple enumeration values have the same underlying value (i.e., as aliases) (I propose yes).
> -Can the underlying type be a non-integral type (I don't see the need if the URL syntax and serialization formats uses the enumeration value name)
> We need a single proposal that defines all the additional text required to fully support enumerations.

-- 
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]