[Swaroop: note the bit about :VAL at the end!] The following will be added to the BitC specification when I can get a decent link.
Last week, Swaroop and I noticed a glitch in the type declaration mechanism: we were unable to declare an ML-style list. PROBLEM: The declaration: (defunion (list 'a) nil (cons 'a (list 'a))) is (correctly) illegal, because LIST is not a reference type and it is incomplete at the time it is used on the right-hand side. The correct declaration would be: (defunion (list 'a) nil (cons 'a (ref (list 'a)))) However, this is very awkward, because note that CONS cannot be used in the obvious way. The following is illegal: (cons #\a (cons #\b nil)) and must instead be written as something like: (cons #\a (ref (cons #\b nil))) This is terrible. SOLUTION: We have added syntax to DEFUNION and DEFSTRUCT. One can now write: (defunion (list 'a) : ref nil (cons 'a (list 'a))) The presence of ":ref" after the type declaration indicates that a reference type is being declared, and that the constructors should produce an object that is allocated from the heap. Purely for the sake of symmetry, we should also add syntax ":val", equivalent to ":ref", indicating explicitly that the type being declared is a value type. shap _______________________________________________ bitc-dev mailing list [email protected] http://www.coyotos.org/mailman/listinfo/bitc-dev
