This is the closest thing I can think of:
import macros
macro dotAccess(o: typed, str: static[string]): untyped =
# Macro to do `o.str`, probably not the best way
newDotExpr(o,newIdentNode(str))
type
DataTable = concept x
x is tuple|object
for f in fields(x):
f is seq # your example had `x` here, wich didn't really make sense
to me,
# as if x is tuple or object it can't be seq, no?
OrderedDataTable[key: static[string]] = concept od
od is DataTable
od.dotAccess(key) is seq # Checks that `od` has field `key`
od.k == key # check the key of the concept matches the key of the object
MyDt[k:static[string]] = object
a: seq[int]
b: seq[float]
var ob: MyDt["a"]
echo ob is DataTable # true
echo ob is OrderedDataTable["b"] # false
echo ob is OrderedDataTable["a"] # true
I don't really know how you would access `key` if it wasn't stored in the
object type.
( looking at the generated C, looks like `MyDt` is a struct with fields `a` and
`b`, so it should be the same binary representation? I think I remember reading
that generics exists only for the nim compiler, they do not affect the C code)