@@ -751,6 +751,11 @@ In other words, the return type of tag types is allowed to be non-empty.
751751We also introduce tag uses, which can be either tag indices or tag addresses:
752752
753753- ` taguse ::= tagidx | tagaddr `
754+ - ` $a : [t1*] -> [t2*] `
755+ - iff ` C.tags[$e] = tag $ft `
756+ - and ` C.types[$ft] ~~ func [t1*] -> [t2*] `
757+ - ` ea : [t1*] -> [t2*] `
758+ - iff ` S.tags[ea].type ~~ [t1*] -> [t2*] `
754759
755760### Instructions
756761
@@ -799,45 +804,25 @@ This abbreviation will be formalised with an auxiliary function or other means i
799804
800805- ` hdl = (on <taguse> <labelidx>) | (on <taguse> switch) `
801806 - Handlers attached to ` resume ` and ` resume_throw ` , handling control tags for ` suspend ` and ` switch ` , respectively.
802- - ` (on $e $l) : t* `
803- - iff ` C.tags[$e] = tag $ft `
804- - and ` C.types[$ft] ~~ func [t1*] -> [t2*] `
805- - and ` C.labels[$l] = [t1'* (ref null? $ct)] `
806- - and ` t1* <: t1'* `
807- - and ` C.types[$ct] ~~ cont [t2'*] -> [t'*] `
808- - and ` [t2*] -> [t*] <: [t2'*] -> [t'*] `
809- - ` (on ea $l) : t* `
810- - iff ` S.tags[ea].type ~~ [t1*] -> [t2*] `
807+ - ` (on tu $l) : t* `
808+ - iff ` tu : [t1*] -> [t2*] `
811809 - and ` C.labels[$l] = [t1'* (ref null? $ct)] `
812810 - and ` t1* <: t1'* `
813811 - and ` C.types[$ct] ~~ cont [t2'*] -> [t'*] `
814812 - and ` [t2*] -> [t*] <: [t2'*] -> [t'*] `
815- - ` (on $e switch) : t* `
816- - iff ` C.tags[$e] = tag $ft `
817- - and ` C.types[$ft] ~~ func [] -> [t*] `
818- - ` (on ea switch) : t* `
819- - iff ` S.tags[ea].type ~~ [] -> [t*] `
813+ - ` (on tu switch) : t* `
814+ - iff ` tu : [] -> [t*] `
820815
821816- ` suspend <taguse> `
822817 - Use a control tag to suspend the current computation.
823- - ` suspend $e : [t1*] -> [t2*] `
824- - iff ` C.tags[$e] = tag $ft `
825- - and ` C.types[$ft] ~~ func [t1*] -> [t2*] `
826- - ` suspend ea : [t1*] -> [t2*] `
827- - iff ` S.tags[ea].types ~~ func [t1*] -> [t2*] `
818+ - ` suspend tu : [t1*] -> [t2*] `
819+ - iff ` tu : func [t1*] -> [t2*] `
828820
829821- ` switch <typeidx> <taguse> `
830822 - Switch to executing a given continuation directly, suspending the current execution.
831823 - The suspension and switch are performed from the perspective of a parent ` (on $e switch) ` handler, determined by the annotated control tag.
832- - ` switch $ct1 $e : [t1* (ref null $ct1)] -> [t2*] `
833- - iff ` C.tags[$e] = tag $ft `
834- - and ` C.types[$ft] ~~ func [] -> [t*] `
835- - and ` C.types[$ct1] ~~ cont [t1* (ref null? $ct2)] -> [te1*] `
836- - and ` te1* <: t* `
837- - and ` C.types[$ct2] ~~ cont [t2*] -> [te2*] `
838- - and ` t* <: te2* `
839- - ` switch $ct1 ea : [t1* (ref null $ct1)] -> [t2*] `
840- - iff ` S.tags[ea].types ~~ func [] -> [t*] `
824+ - ` switch $ct1 tu : [t1* (ref null $ct1)] -> [t2*] `
825+ - iff ` tu : [] -> [t*] `
841826 - and ` C.types[$ct1] ~~ cont [t1* (ref null? $ct2)] -> [te1*] `
842827 - and ` te1* <: t* `
843828 - and ` C.types[$ct2] ~~ cont [t2*] -> [te2*] `
@@ -941,18 +926,18 @@ H^ea ::=
941926* ` S; F; (suspend $e) --> S; F; (suspend ea) `
942927 - iff ` ea = F.module.tags[$e] `
943928
944- * ` S; F; (prompt{hdl1* (ea $l) hdl2*} H^ea[v^n (suspend ea)] end) --> S'; F; v^n (ref.cont |S.conts|) (br $l) `
945- - iff ` forall $l', (ea $l') notin hdl1* `
929+ * ` S; F; (prompt{hdl1* (on ea $l) hdl2*} H^ea[v^n (suspend ea)] end) --> S'; F; v^n (ref.cont |S.conts|) (br $l) `
930+ - iff ` forall $l', (on ea $l') notin hdl1* `
946931 - and ` S.tags[ea].type ~~ [t1^n] -> [t2^m] `
947932 - and ` S' = S with conts += (H^ea : m) `
948933
949934* ` S; F; (switch $ct $e) --> S; F; (switch $ct ea) `
950935 - iff ` ea = F.module.tags[$e] `
951936
952- * ` S; F; (prompt{hdl1* (ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch $ct ea)] end) --> S''; F; prompt{hdl1* (ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end `
937+ * ` S; F; (prompt{hdl1* (on ea switch) hdl2*} H^ea[v^n (ref.cont ca) (switch $ct ea)] end) --> S''; F; prompt{hdl1* (on ea switch) hdl2*} E[v^n (ref.cont |S.conts|)] end `
953938 - iff ` S.conts[ca] = (E : n') `
954939 - and ` n' = 1 + n `
955- - and ` (switch ea) notin hdl1* `
940+ - and ` (on switch ea) notin hdl1* `
956941 - and ` $ct ~~ cont $ft `
957942 - and ` $ft ~~ [t1* (ref $ct2)] -> [t2*] `
958943 - and ` $ct2 ~~ cont $ft2 `
0 commit comments