I'm new to Scala macros, so sorry if this is an obvious question.
I wonder if the following is even possible before I dig in deeper.
Let's say I have a class named DynamicProperties
Is it possible to add members to the class based on something like this?
val x: DynamicProperties = ...
x.addProperty("foo", 1)
x.addProperty("bar", true)
x.addProperty("baz", "yep")
and have it be translated somehow to a class that looks like this more or less?
class SomeName extends DynamicProperties {
val foo: Int = 1
val bar: Boolean = true
val baz: String: yep
}
I guess this can be done via reflection, but I want people who use this, to have auto complete when they type x.
that will fit what they did earlier using the addProperty
method. Is this possible using Scala marcos? I want to try to implement it, but it will be good to know if this is going down a dead end path or not.