Get unknown symbol (struct, method, class) tagged with User Defined Attributes
Doug
overprose at gmail.com
Wed May 13 02:07:41 UTC 2020
On Tuesday, 12 May 2020 at 04:02:18 UTC, Steven Schveighoffer
wrote:
> In the case of serialization/deserialization, you give an
> instance of a type to serialize or deserialize. Then the
> library can search the symbols inside that type to see if any
> has the UDA you are looking for.
>
> In the Rust example, there is a line of code:
>
> let p: Person = serde_json::from_str(data)?;
>
> I'm assuming that this conversion is detected and figured out
> (i.e. this is how serde "finds" the type desired). For D, it
> would look something like:
>
> auto p = serde_json.from_str!Person(data);
>
> If you want a list of ALL symbols that have the UDA in the
> application, that would require some form of runtime reflection
> (like Java). D has very limited support for runtime reflection.
> In D, you would use some form of registration to tell the
> system about your symbols.
>
> -Steve
Thanks for the feedback.
I've got a better idea of what is and isn't possible now.
I'll see about looking at one or two D JSON libraries to see how
they approach things. It should help shed some more light on the
subject.
More information about the Digitalmars-d-learn
mailing list