Paste: clay - computed records
Author: | kssreeram |
Mode: | factor |
Date: | Sun, 9 May 2010 03:01:04 |
Plain Text |
record ComputedRecord {
...ComputeFields();
}
ComputeFields() = ((#foo, Int), (#bar, Bool));
is equivalent to
record ComputeRecord {
foo : Int;
bar : Bool;
}
Here is an implementation of SwizzledVector. A swizzled vector of a record T becomes a record of vectors of the fields of T.
record SwizzledVector[T] {
...SwizzleFields(...RecordFields(T));
}
overloadable SwizzleFields;
overload SwizzleFields() = ();
overload SwizzleFields(a, ...b) = (SwizzleOne(...a), ...SwizzleFields(...b));
SwizzleOne(name, type) = (name, Vector[type]);
New Annotation