Changeset 14122

Show
Ignore:
Timestamp:
10/09/06 17:26:37 (2 years ago)
Author:
audreyt
Message:

* Pugs.Monad: Establish a resetT boundary upon entering

coroutines, so its "yield" will only capture the control
stack up to that point. However, the &?CALLER_CONTINUATION
there is unaffected.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Monads.hs

    r14113 r14122  
    186186         -> Eval Val -- ^ Result of passing the pad-transformer to the  
    187187                     --     \'action\' 
    188 genSymCC symName action = catchT $ \esc -> do 
     188genSymCC symName action = callCC $ \esc -> do 
    189189    genSymPrim symName (const $ esc undef) action 
    190190 
     
    201201    | otherwise     = do 
    202202        env <- ask 
    203         rv  <- if typ >= SubBlock 
    204             then resetT $ do 
     203        rv  <- case typ of 
     204            _ | typ >= SubBlock -> tryT $ do 
    205205                doFix <- fixEnv return env 
    206206                local doFix runAction 
    207             else resetT . catchT $ \cc -> do 
     207 
     208            -- For coroutines, we secretly store a continuation into subCont 
     209            -- whenever "yield" occurs in it.  However, the inner CC must be 
     210            -- delimited on the subroutine boundary, otherwise the resuming 
     211            -- continuation will continue into the rest of the program, 
     212            -- which is now how coroutines are supposed to work. 
     213            -- On the other hand, the normal &?CALLER_CONTINUATION must still 
     214            -- work as an undelimiated continuation, which is why callCC here 
     215            -- occurs before resetT. 
     216            SubCoroutine -> tryT . callCC $ \cc -> resetT $ do 
     217                doFix <- fixEnv cc env 
     218                local doFix runAction 
     219 
     220            _ -> tryT . callCC $ \cc -> do 
    208221                doFix <- fixEnv cc env 
    209222                local doFix runAction