4 REM allocate the data hashmap
8 REM set the outer and data pointer
9 T
=13:L
=R
:M
=C
:GOSUB ALLOC
10 GOSUB RELEASE
: REM environment takes ownership
13 REM see RELEASE types.in.bas for environment cleanup
15 REM ENV_NEW_BINDS(C, A, B) -> R
21 IF Z
%(A
+1)=0 THEN R
=E
:RETURN
22 REM get/deref the key from A
25 IF S
$(Z%(K+1))="&" THEN GOTO EVAL_NEW_BINDS_VARGS
28 REM get/deref the key from B
30 REM set the binding in the environment data
32 REM go to next element of A and B
35 GOTO ENV_NEW_BINDS_LOOP
38 REM get/deref the key from next element of A
41 REM the value is the remaining list in B
42 A
=B
:T
=6:GOSUB FORCE_SEQ_TYPE
44 REM set the binding in the environment data
47 AY
=C
:GOSUB RELEASE
: REM list is owned by environment
50 REM ENV_SET(E, K, C) -> R
58 REM ENV_SET_S(E, B$, C) -> R
66 REM ENV_FIND(E, K) -> R
67 REM Returns environment (R) containing K. If found, value found is
73 REM More efficient to use GET for value (R) and contains? (R3)
75 REM if we found it, save value in R4 for ENV_GET
76 IF R3
=1 THEN R4
=R
:R
=T
:GOTO ENV_FIND_DONE
77 T
=Z
%(T
+2): REM get outer environment
78 IF T
>0 THEN GOTO ENV_FIND_LOOP
83 REM ENV_GET(E, K) -> R
86 IF R
=-1 THEN ER
=-1:E
$="'"+S$(Z%(K+1))+"' not found
":GOTO ENV_GET_RETURN