Paste: permissive record constructor in clay

Author: kssreeram
Mode: text
Date: Sun, 29 Aug 2010 16:20:52
Plain Text |

//
// permissive record constructor
//

PermissiveRecordConstructor?(x) = false;

[T, ...A | Record?(T)
           and PermissiveRecordConstructor?(T)
           and (countValues(...A) == countValues(...RecordFieldTypes(T)))]
T(...args:A) returned:T {
    returned <-- T();
    alias n = RecordFieldCount(T);
    static for (i in ...staticIntegers(static n)) {
        ref field = staticIndex(returned, i);
        ref value = nthValue(i, ...args);
        permissiveAssign(field, value);
    }
}

New Annotation

Summary:
Author:
Mode:
Body: