static  A optParam(ThreadLocal tl, A defaultValue) {
  ret optPar(tl, defaultValue);
}
static  A optParam(ThreadLocal tl) {
  ret optPar(tl);
}
static O mapMethodLike optParam(S name, Map params) {
  ret mapGet(params, name);
}
// now also takes a map as single array entry
static  A optParam(O[] opt, S name, A defaultValue) {
  int n = l(opt);
  if (n == 1 && opt[0] instanceof Map) {
    Map map = cast opt[0];
    ret map.containsKey(name) ? (A) map.get(name) : defaultValue;
  }
  if (!even(l(opt))) fail("Odd parameter length");
  for (int i = 0; i < l(opt); i += 2)
    if (eq(opt[i], name))
      ret (A) opt[i+1];
  ret defaultValue;
}
sO optParam(O[] opt, S name) {
  ret optParam(opt, name, null);
}
sO mapMethodLike optParam(S name, O[] params) {
  ret optParam(params, name);
}