Ok, so here's the core advantage of BEXPR_prj (n,d,c),d->c
This term is projection number "n" from type d to type c. For example given struct X { int a; double b; double c; }; we have three projections: prj0: X -> int prj1: X -> double prj2: X -> double At present, we can write: var x = X (1, 4.2,1.4); var xc = x . c; // prj2 var xb = x . b; // prj1 but we cannot write: var p = &X::b; // prj1 var d = x .p; which we CAN do in C++. Here p is a projection *variable*, i.e. an expression yielding a projection of a known type, but it is not known which one it is. The new BEXPR_prj has a *run time* representation. First, we can do this anyhow: fun proj1 (x:X) => x.b; var d = x . proj1; remember, operator . is just reverse application! This one is a bit tricker though: fun proj1 (px: &X) =? px . b; (&x) . proj1 <- 7.3; The representation at run time is of course just an offset. In C you can add offsets but it isn't safe, in C++ offsets are safer but you can't add them. Addition of offsets is just functional composition. Now, there's another trick here: compact linear types. There is an "offset" to one of them too, but its the divisior required to shift the value right inside an integer to the units position (the modulus which masks higher parts out is given by the size of the type). What this means is that to compose two projections to compact linear terms, we divide, then we divide again. In other words, the projections are just multiplied! There's a deep lesson here. The whole of your address space can be considered compact linear. Ordinary addressing by addition of offsets, but that's a special case! The general case is just multiplication, and the obvious relation is a logarithm. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language