Merge pull request #24 from nineties/add-enum

Add "enum"
This commit is contained in:
Koichi NAKAMURA 2021-12-08 06:13:45 +09:00 committed by GitHub
commit 8a3d114ae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -40,4 +40,18 @@ end-struct cons-cell%
: car first @ ; export
: cdr second @ ; export
( === Enum === )
\ 0
\ enum A
\ enum B
\ drop
\ 0 constant A
\ 1 constant B
: enum ( n "name" -- n )
dup constant 1+
; export
}private

View file

@ -1013,4 +1013,10 @@ T{ cons0 cdr -> 1 }T
cons0 free
\ ------------------------------------------------------------------------
testing enum
T{ 0 enum e0 enum e1 enum e2 drop -> }T
T{ e0 -> 0 }T
T{ e1 -> 1 }T
T{ e2 -> 2 }T