Changeset 12002 for src/Pugs/Val

Show
Ignore:
Timestamp:
08/08/06 17:55:39 (2 years ago)
Author:
audreyt
Message:

* Finally, an extremely sane treatment for item/list contexts.

both only occur in ByVal? (i.e. when the return continuation is
expecting something not "is rw").


The compiler inserts a runtime dispatch of .item or .list on the
term (usually a container).

A user-defined object can elect to return its content
(like Scalar.item, Scalar.list and Array.list) or not
(like Array.item, Hash.item and Int.list).

The choice in Hs level is controlled in asList and asItem
method; the P6 level equivalence would be ".item" and ".list"
unless later overruled. :-)

* Bridged this treatment to oldland VV as well.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Val/Str.hs

    r12000 r12002  
    2323    asStr    :: a -> m PureStr 
    2424    asStr x = return (cast "<opaque>") -- XXX wrong 
     25    -- "$item = VAL" 
     26    asItem   :: a -> Maybe (m Val) 
     27    asItem _ = Nothing -- default = do nothing (for Scalar this would return its content) 
     28    -- "@list = VAL" 
    2529    asList   :: a -> Maybe (m PureList) 
    26     asList _ = Nothing -- default = do not flatten 
     30    asList _ = Nothing -- default = do nothing (for Scalar this would return its content wrapped in a 1-seq) 
    2731    asNative :: a -> m ValNative 
    2832    asNative = fmap (NBuf . cast) . asStr