ocaml-ppx / ppxlib

Base library and tools for ppx rewriters
MIT License
248 stars 95 forks source link

Question on writing deriver for class #509

Open Wenke-D opened 1 month ago

Wenke-D commented 1 month ago

It appears impossible to get the attache class AST using context free transformation.

class apple = object
   ...
end [@@inspect]

in the ppxlib, Deriving.add do not have the optional arg to get class_declaration list.

Did I miss something or it is indeed impossible.

Thanks !

Wenke-D commented 1 month ago

The objective is to inspect the methods and fields the class, then generate some functions outside.

NathanReb commented 1 month ago

Yes indeed it seems it's not supported. Off the top of my head I can't think of a reason why we wouldn't add support for this!