Skip to content
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

Propose an Enumeration Type #17

Open
adamretter opened this issue Nov 24, 2018 · 1 comment
Open

Propose an Enumeration Type #17

adamretter opened this issue Nov 24, 2018 · 1 comment

Comments

@adamretter
Copy link
Member

adamretter commented Nov 24, 2018

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"
};
@michaelhkay
Copy link
Member

michaelhkay commented Nov 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants