Changeset 14079 for src/Pugs/Eval.hs

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

* Pugs.Eval: Syn "block" [...] can now double as a runtime-creation-only

closure for things that does not want to close over the compile-time
block, typically when there wasn't a real block in the first place.

This is useful for postfix loops as well as implicit hypers.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r14071 r14079  
    14711471 
    14721472fromCodeExp :: Exp -> Eval VCode 
    1473 fromCodeExp = (fromVal =<<) . enterRValue . enterEvalContext (cxtItem "Code") 
     1473fromCodeExp x = case x of 
     1474    Syn "block" [Val VCode{}]   -> fromClosure x 
     1475    Syn "block" [_]             -> do 
     1476        env <- ask 
     1477        return $ mkCode 
     1478            { subEnv        = Just env 
     1479            , subType       = SubBlock 
     1480            , subParams     = [defaultScalarParam] 
     1481            , subBody       = x 
     1482            } 
     1483    _                           -> fromClosure x 
     1484    where 
     1485    fromClosure = (fromVal =<<) . enterRValue . enterEvalContext (cxtItem "Code") 
     1486