Changes between Version 53 and Version 54 of DataParallel/ClosureConversion/ClassLess

May 1, 2007 8:04:56 AM (8 years ago)



  • DataParallel/ClosureConversion/ClassLess

    v53 v54  
    113113    toArr f        = const (tob . f . fra) :$ () 
    114114    frArr (f :$ e) = frb . f e . toa 
     117=== Conversions === 
     119To perform the actual conversion of values of a type `t::*`, we generate a conversion `iso<t>` of type `t :<->: t^` as follows: 
     121iso<T>          = isoT           , if T_CC exists 
     122                = idIso<*>       , otherwise 
     123iso<a::k>       = idIso<k> 
     124iso<t1 -> t2>   = idIso<*>       , if kindOf t1 == # 
     125                                   or kindOf t2 == # 
     126                = isoArr         , otherwise  
     127                    iso<t1> iso<t2> 
     128iso<t1 t2>      = iso<t1> iso<t2> 
     129iso<forall a.t> = iso<t> 
     133idIso<*>      = id :<->: id 
     134idIso<k1->k2> = \_ -> (idIso<k2>) 
    255275 * We come across a dfun: If its `idCC` field is `NoCC`, we keep the selection as is, but apply `convert t e` from it, where `t` is the type of the selected method and `e` the selection expression.  If `idCC` is `ConvCC d_CC`, and the dfun's class is converted, `d_CC` is fully converted.  If it's class is not converted, we also keep the selection unconverted, but have a bit less to do in `convert t e`.  '''TODO:''' This needs to be fully worked out. 
    257 === Generating conversions === 
    259 Whenever we had `convert t e` above, where `t` is an unconverted type and `e` a converted expression, we need to generate some conversion code.  This works roughly as follows in a type directed manner: 
    260 {{{ 
    261 convert T          = id   , if tyConCC T == NoCC or AsIsCC 
    262                    = to_T , otherwise 
    263 convert a          = id 
    264 convert (t1 t2)    = convert t1 (convert t2) 
    265 convert (t1 -> t2) = createClosure using (trevnoc t1)  
    266                      and (convert t2) on argument and result resp. 
    267 }}} 
    268 where `trevnoc` is the same as `convert`, but using `from_T` instead of `to_T`. 
    270 The idea is that conversions for parametrised types are parametrised over conversions of their parameter types.  Wherever we call a function using parametrised types, we will know these type parameters (and hence can use `convert`) to compute their conversions.  This fits well, because it is at occurences of `Id`s that have `idCC == NoCC` where we have to perform conversion. 
    272 The only remaining problem is that a type parameter to a function may itself be a type parameter got from a calling function; so similar to classes, we need to pass conversion functions with every type parameter.  So, maybe we want to stick `fr` and `to` into a class after all and requires that all functions used in converted contexts have the appropriate contexts in their signatures. 
    274278=== TODO ===