scala - Can I add class fields dynamically using macros? -
i'm new scala macros, sorry if obvious question.
i wonder if following possible before dig in deeper.
let's have class named dynamicproperties
is possible add members class based on this?
val x: dynamicproperties = ... x.addproperty("foo", 1) x.addproperty("bar", true) x.addproperty("baz", "yep")
and have translated somehow class looks more or less?
class somename extends dynamicproperties { val foo: int = 1 val bar: boolean = true val baz: string: yep }
i guess can done via reflection, want people use this, have auto complete when type x.
fit did earlier using addproperty
method. possible using scala marcos? want try implement it, know if going down dead end path or not.
Comments
Post a Comment