Changes between Version 25 and Version 26 of StaticPointers/ImplementationPlan


Ignore:
Timestamp:
Dec 7, 2014 1:04:33 AM (5 years ago)
Author:
facundo.dominguez
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • StaticPointers/ImplementationPlan

    v25 v26  
    1717The proposal is therefore to:
    1818
    19 * Implement the extension in two phases: the full version with full dynamic type checks on top of a revised `Data.Typeable` in GHC 7.12, but an interim version in GHC 7.10 '''with the exact same API''' but with the dynamic type checks enabled by the SPT missing.
     19* Implement the extension in two phases: the full version with full dynamic type checks on top of a revised `Data.Typeable` in GHC 7.12, but an interim version in GHC 7.10 '''with a similar API''' but missing the dynamic type checks enabled by the SPT.
    2020
    2121* In GHC 7.10, ''implement only a shim SPT'', that looks just like the real thing, but does not include `tTypeRep`s or `TypeRep`s for any value. The reason we still need an SPT in GHC 7.10 is because there needs to be something that references static expressions throughout the lifetime of the program. The reason is that any such expression may at any time be referenced by a new `StaticPtr` produced from an incoming message. In other words, in a distributed system, other nodes may refer to values that are otherwise not live on the local node. The SPT must itself be protected against garbage collection, e.g. through the use of a `StablePtr`.
    22 
    23 * In GHC 7.10, possibly only allow identifiers in the body of a `static` form, depending on the time required to implement floating of expressions to top-level adequately. This isn't a loss of generality, but is a loss of convenience for the user: one would have to float all expressions as top-level definitions manually.
    2422
    2523=== The API of `GHC.StaticPtr` (interim version for 7.10) ===
     
    5250'''Remarks:'''
    5351
    54 * `deRefStaticPtr` so named to make its name consistent with `deRefStablePtr` in `GHC.StablePtr`. Other possibilities include `unstatic` or `unStaticPtr`.
     52* `deRefStaticPtr` so named to make its name consistent with `deRefStablePtr` in `GHC.StablePtr`.
    5553* This module will be added to `base`, as for other primitives exposed by the compiler. This means we cannot depend on `bytestring` or any other package except `ghc-prim`.
    5654* As such, we should leave it up to user libraries how they wish to encode `StaticPtr`, using whatever target type they wish (e.g. `ByteString`). The solution is to provide a serializable `StaticKey` for each `StaticPtr`.
     
    6664data StaticPtr a = StaticPtr !Fingerprint StaticPtrInfo a
    6765  deriving Typeable
    68 
    69 instance Show (StaticPtr a) where
    70   show (StaticPtr fp nfo _) = "StaticPtr " ++ show fp ++ " " ++ show nfo
    7166}}}
    7267
     
    7469  * '''Lexical analysis''': `static` is a keyword when `-XStaticPointers` is on[[BR]][[BR]]
    7570  * '''Parsing''': new constructor `HsStatic` in `HsExpr`, to represent `(static e)`.[[BR]][[BR]]
    76   * '''Renaming''': in `(static e)`, check that all free variables of `e` are bound at top level[[BR]][[BR]]
    77   * '''Typechecking'''. In the type checker, we add `Typeable a` to the set of constraints.[[BR]][[BR]]
    78   * '''Desugaring''': desugar `(static e)` to ??, and create a new top-level binding
     71  * '''Renaming''': in `(static e)`, check that all free variables of `e` are bound at top level. And check that static does not occur in splices (but can occur in quotations).[[BR]][[BR]]
     72  * '''Typechecking'''. In the type checker, we add `Typeable a` to the set of constraints, and we treat the body of the static form as if it were a top level definition.[[BR]][[BR]]
     73  * '''Desugaring''': desugar `(static e)` to `sptEntry:0`, and create a new top-level binding
    7974{{{
    80 sptEntry:0 :: DynStaticPtr
    81 sptEntry:0 = toDynamic (StaticPtr (Fingerprint ...) e)
     75sptEntry:0 :: StaticPtr (type of e)
     76sptEntry:0 = StaticPtr (fingerprintString "packageId:module.sptEntry:0")  (StaticPtrInfo ...) e
    8277}}}
    8378  where `sptEntry:0` is a fresh name.[[BR]][[BR]]