On this page:
enum
8.13.0.9

6.50 Enumerations🔗ℹ

definition

enum id_name:

  enum_clause

  ...

 

enum_clause

 = 

id ...

 | 

~is_a: annot; ...

 | 

~is_a annot

Defines id_name as a predicate annotation and as a namespace, where the namespace exports each id as the symbol #'id and as a binding form that matches the symbol #'id. The annotation is satisfied by each symbol #'id and by values satisfying any of the annots specified with ~is_a. The intersection of annots’ associated static information (and Symbol’s, if any id is present) are associated with the resulting annotation.

The ids and annots are tried in sequence, even when they are interleaved. Like is_a, the converting part of any converter annotation annot will not be used.

enum Mouse:

  itchy

  mickey minnie

  jerry

> Mouse.itchy

#'itchy

> #'itchy is_a Mouse

#true

> #'scratchy is_a Mouse

#false

> match #'jerry

  | Mouse.itchy: "scratchy"

  | Mouse.jerry: "tom"

"tom"

enum Cat:

  ~is_a String

  scratchy

  tom

> Cat.tom is_a Cat

#true

> "Felix" is_a Cat

#true