Skip to content

Propose an Enumeration Type #17

Description

@adamretter

I have no idea right now how this would work or what it would look like! However, I have a feeling that the ability to define a sealed type of enumerations could be useful.

For example if I have a function like compute-checksum($algorithm, $data), it might be useful if I could define that the $algorithm is one of a number of enumerated (supported) values and nothing else.

A further example to start a discussion:

declare enumeration local:animal := {
    CAT
    DOG
    PIG
};

declare function local:sound($animal as enumeration(local:animal)) as xs:string {
    if ($animal eq local:animal:CAT) then
        "meow"
    else if ($animal eq local:animal:DOG) then
        "woof"
    else
        "oink"
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions