I noticed a problem with the Cardelli optimizations today. Given: (defunion (nullable 'a) :val Null (not-null ptr:(ref 'a))
We would very much like Null to be represented by a zero pointer for cross-language compatibility. The current tag encoding requirement makes it 1. I set out to repair this by making single-reference unions with a single enumeration tag use the null pointer explicitly. But then I realized that given: (defunion (list 'a) nil (cons 'a (list 'a))) The type (list (ref 'a)) will encode NIL as a null pointer, but the type (list (nullable 'a)) will end up introducing a tag word. This is not wonderful. Note that NULLABLE is not quite the same as OPTIONAL: (defunion (optional 'a) :val none (some value:'a)) because OPTIONAL does not ensure a reference type in the OPTIONAL.some leg. It is possible that I got the definition of OPTIONAL mixed up; in its current form I think that OPTIONAL is a low-use case, and I'm not at all convinced that it is useful enough to be a foundational type. For this reason, I want to add NULLABLE to the preamble as a foundational type. Having done so, I want to add a special case representation rule that Null:(nullable 'a) is always represented as zero. Having done that, I can expand the coverage of the current Cardelli rules from single-reference to include single-opt. Under the expanded rules, both (list (ref 'a)) and (list (nullable 'a)) will both be able to use two-word CONS cells, and that in both cases the tag value used for NIL will be 1. Anybody see a body buried here that I may be missing? shap _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
