`[<<][meta][>>][..]`
Fri Dec 30 12:00:16 EST 2011

## Horrible hack

```Horribly wrong.  Don't try this at home.  But intriguing nontheless.
How can this be so wrong?

-- Virtual data structures.  Used by SArray
instance StructRepr Code where
atom (L (Code t))        = Code t
cons (Code t, _)         = Code t
nil  ()                  = Code Nil

unatom (Code t)          = L (Code t)
uncons (Code t)          = (Code t, Code t)
unnil  (Code Nil)        = ()

b19 (L arri) = do
xs <- _get' arri (lit 0)
(L x1, L x2) <- _unpack xs
y <- add x (lit (1 :: Tfloat))
_ret y
f19 =   _def "fun" \$ _lambda b19
t19 = ctop \$ term \$ f19

struct tuple_f1_f1 {
float * m0; float * m1;
};
float fun(struct tuple_f1_f1 a0)
{
const struct tuple_f1_f1 t1 = a0;
const struct tuple_f1_f1 t2 = a0;
const float a3 = t1.m0;
const float a4 = t1.m1;
const float t5 = a3 + a4;
const float t6 = t5 + 1.0;
return t6;
}

It seems that what is really missing is just representation of
structure indexing.  Something like

uncons (Code (Ref (Var ...))) = (Code (RefCar (Var ...)),
Code (RefCdr (Var ...)))

It seems simpler to use this as structure representations, and solve
the flattening in PrettyC.

The C code then would become something like this:

struct tuple_f1_f1 {
float * m0; float * m1;
};
float fun(struct tuple_f1_f1 a0)
{
const struct tuple_f1_f1 t1 = a0.car;
const struct tuple_f1_f1 t2 = a0.cdr;
const float a3 = t1.m0;
const float a4 = t1.m1;
const float t5 = a3 + a4;
const float t6 = t5 + 1.0;
return t6;
}

Let's see what happens when we go to bigger trees.

No no no... This is wrong.  The line "t1.m0" doesn't make sense.

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