[<<][meta][>>][..]
Sun Dec 18 12:08:11 EST 2011

PrettC : monadic generator necessary?

Bummer.. It looks like the PrettyC Term -> AST conversion can't be
done with a local transformation due to the fact that local struct
definitions (I.e. inside function arguments) are not possible in C.

Wait, the following might work to at least simulate that, and
side-step the non-local AST building necessary for global struct
declarations:

  int foo_op(void *arg1_v) {
    struct tuple_b0_i1_f2 {
      int mem0; int * mem1; float * * mem2;
    } *arg1 = arg1_v;
    return arg1->mem0;
  }

This keeps the type definition local to the function.  Initialization
can then be hidden behind functions also:

  void foo_init(void *varg1) {
    struct tuple_b0_i1_f2 {
      int mem0; int * mem1; float * * mem2;
    } *arg1;
    arg1->mem0 = 0;
    arg1->mem1 = 0;
    arg1->mem2 = 0;
  }

  int foo_size(void) {
    struct tuple_b0_i1_f2 {
      int mem0; int * mem1; float * * mem2;
    } *arg1;
    return sizeof(*arg1);
  }

Yep, compiles fine.  Let's go for that.

What about Term DestructureLet?  Yeah, but we need assignment too.

What about extending Get / Set to operate on structure types also?
Maybe it already just works?  There seems to be no restriction on the
_get / _set of the Array class?


  class TML m r => Array m r a t | r -> a  where

    _get   :: r (a t) -> r Tint -> m (r t)
    _set   :: r (a t) -> r Tint -> r t ->  m (r ())


For now, let's just add a separate _getStruct _setStruct, and require
Struct constraints like _app and _lambda.





[Reply][About]
[<<][meta][>>][..]