@Araq:
An object does not only consist of fields, it can have case and when etc.
Which is part of the reason why doing something as simple as getting the fields robustly gets difficult when dealing directly with the AST; there isn't just one canonical representation. I thought the compiler might have such a canonical representation internally which can be queried, but I guess not.
@chrisheller:
Keep in mind that you can write some of your own compile time methods
I did write my own (partial) solution. It just doesn't work for every valid tree configuration as of yet. If the plan is to write an API on top of the AST one anyway, then I guess I'll just keep building up on mine and release it eventually as a library when it becomes robust. Then someone could integrate into Nim core if it comes out any good.
@Araq
The idea always was to have more convenient accessors for the ASTs that getType returns. But for now we're stuck with the primitives.
doesn't this solve the problem?
type
A=object
x1:int
x2:string
for name, value in A().fieldPairs:
echo name # etc
(modulo this bug https://github.com/nim-lang/Nim/issues/7533)