At present compact linear types ONLY work with combinations of units. However once they're working solidly, this will change. A union or enum will use the same model if possible.
Let me give an example explaining why they're usefui. Suppose we have to monitor the state of a file handle. It could be: (0) Invalid, never used (1-3) Invalid, open failed for reason 1,2 or 3 (4) open-read-ready (5) open-write (6) open-read-at-end (7) closed These conditions are clearly mutually exclusive and compact linear, and would use exactly 3 bits to encode. However the structure is a bit messy. Another way would be: union state = | Invalid of invalidity | Valid of validity ; union invalidity = | Unused | OpenError of openerror | Closed union openerror = | Error1 | Error2 | Error3 ; union validity = | OpenRead of readstate | OpenWrite ; union readstate = | Ready | AtEnd ; These unions are a lot easier to encode and decode for the programmer than a simple enumeration, but represents the same set of states. With suitable changes to the encoding of unions, it is clear "state" can be represented in 3 bits as a compact linear type. In fact, you can do this right now with a typedef instead of a unions, and macro vals (UGG) for the case names (macro vals are the only construction which can be used for a constructor which work in a pattern match). In general, the current union representation would use a tagged pointer to heap allocated objects, themselves tagged pointers, etc. This eliminates the unsafety with C flags where you have things like: Bit 0 can be true or false If bit 0 is true, bit 1 can be true or false, otherwise we don't care So the meaning of bit 1 is contingent on bit 0. Of course proper sum types eliminate the lack of safety here, but previously there was a bit cost. Not only in performance speed or storage use, but also in the ability to save the data to disk. Compact linear types do not eliminate this problem, but they certainly can help to reduce it in many cases. -- john skaller skal...@users.sourceforge.net http://felix-lang.org ------------------------------------------------------------------------------ October Webinars: Code for Performance Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register > http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language