add uda (e.g. @csvIgnore) support in std.csv?
Jacob Carlborg
doob at me.com
Thu Sep 10 14:57:11 UTC 2020
On 2020-09-08 06:53, mw wrote:
> Hi,
>
> I'm trying this example:
>
> https://dlang.org/phobos/std_csv.html
>
> ```
> struct Layout
> {
> string name;
> int value;
> double other;
>
> @csvIgnore
> Layout* parent; // add extra pointer
> }
>
> auto records = text.csvReader!Layout(';');
> ```
>
> Right now, if we add this extra pointer, the compiler will error out:
>
> https://run.dlang.io/is/EvU6Ee
>
> /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(223): Error: template
> std.conv.toImpl cannot deduce function from argument types
> !(Layout*)(string), candidates are:
> ...
>
> I think if we can add add uda (e.g. @csvIgnore) support in std.csv, it
> will make the library more flexible to use.
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 sockets.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list