mirror of
https://github.com/nineties/planckforth
synced 2024-12-26 21:58:42 +01:00
commit
8a3d114ae5
2 changed files with 20 additions and 0 deletions
14
lib/core.fs
14
lib/core.fs
|
@ -40,4 +40,18 @@ end-struct cons-cell%
|
||||||
: car first @ ; export
|
: car first @ ; export
|
||||||
: cdr second @ ; 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
|
}private
|
||||||
|
|
|
@ -1013,4 +1013,10 @@ T{ cons0 cdr -> 1 }T
|
||||||
|
|
||||||
cons0 free
|
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
|
||||||
|
|
Loading…
Reference in a new issue