Changeset 14491 for src/Pugs/Eval.hs

Show
Ignore:
Timestamp:
10/24/06 17:19:32 (2 years ago)
Author:
audreyt
Message:

* Implement maybe {...} maybe {...} STM round-robin retry chains.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r14489 r14491  
    109109        return val 
    110110    when (length val > 100) $ do 
    111         liftIO $ putStrLn "*** Warning: deep recursion" 
    112     liftIO $ putStrLn ("***" ++ val ++ str ++ encodeUTF8 (pretty a)) 
     111        liftSTM . unsafeIOToSTM $ putStrLn "*** Warning: deep recursion" 
     112    liftSTM . unsafeIOToSTM $ putStrLn ("***" ++ val ++ str ++ encodeUTF8 (pretty a)) 
    113113 
    114114evaluateMain :: Exp -> Eval Val 
     
    462462reduceSyn "but" [obj, block] = do 
    463463    evalExp $ App (_Var "&Pugs::Internals::but_block") Nothing [obj, block] 
     464 
     465reduceSyn "maybe" blocks = do 
     466    env     <- ask 
     467    subs    <- mapM fromCodeExp blocks 
     468    let runInSTM sub = runEvalSTM env (apply sub Nothing []) 
     469    guardSTM $ foldl1 orElse (map runInSTM subs) 
    464470 
    465471reduceSyn "if" [cond, bodyIf, bodyElse] = do