add uda (e.g. @csvIgnore) support in std.csv?
schveiguy at gmail.com
Thu Sep 10 19:11:03 UTC 2020
On 9/10/20 1:57 PM, Paul Backus wrote:
> On Thursday, 10 September 2020 at 14:57:11 UTC, Jacob Carlborg wrote:
>> How about a more general attribute in `core.attribute`, like
>> `@nonSerialized`? This could be used by third party serialization
>> libraries. Then it could also be used by druntime and Phobos to ignore
>> things that should not be serializable. Like threads, processes and
> Existing serialization libraries already define their own
> attributes for this sort of thing. I don't think there's anything to be
> gained by attempting to force standardization here.
> If Phobos and/or the D ecosystem does someday decide to standardize on a
> shared @ignore attribute, std.csv can be easily upgraded for
> compatibility by adding `alias csvIgnore = core.attribute.ignore`.
To add to this, I have code that serializes the same types for both
vibe.d JSON for REST interfaces, AND to a database. In one case, I want
certain fields to be ignored (e.g. no reason to send internal database
ids to the browser), and in another case I want other fields to be ignored.
I'd rather have libraries define their own UDAs, and not expect Phobos
to design a UDA system that pleases all parties.
More information about the Digitalmars-d