how to skip empty field in csvReader?

2023-06-05 Thread mw via Digitalmars-d-learn
Hi, https://run.dlang.io/is/9afmT1 ``` void main() { import std.csv; import std.stdio: write, writeln, writef, writefln; import std.algorithm.comparison : equal; string text = "Hello;65;;\nWorld;123;7.5"; struct Layout { string name; int value;

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Ki Rill via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:54:30 UTC, cc wrote: On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? ```d mixin template GenerateSetters() { static foreach (idx, field;

Re: What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
On Monday, 5 June 2023 at 10:43:27 UTC, Ferhat Kurtulmuş wrote: On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom;

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread cc via Digitalmars-d-learn
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? ```d mixin template GenerateSetters() { static foreach (idx, field; typeof(this).tupleof) static if

Re: unittest under betterC

2023-06-05 Thread Ernesto Castellotti via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:14:31 UTC, DLearner wrote: On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote: [...] Thank you for the link, can confirm that: ``` int foo() { [...] It's not so easy to deal automatically in case of multiple modules

Re: unittest under betterC

2023-06-05 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:25:33 UTC, Mike Parker wrote: [...] The docs say it should work: https://dlang.org/spec/betterc.html#unittests [...] Thank you for the link, can confirm that: ``` int foo() { return 4; } unittest { assert(foo() != 4, "!= Assert triggered.");

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 June 2023 at 15:13:43 UTC, Basile B. wrote: On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable although I did not spent time on the setter body... I suppose the question was more about the metprogramming technic, and

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Paul Backus via Digitalmars-d-learn
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? I need this for my [tiny-svg](https://github.com/rillki/tiny-svg) project to generate `setX` methods for all Shapes. Example:

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:29:35 UTC, Richard (Rikki) Andrew Cattermole wrote: On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you

Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? I need this for my [tiny-svg](https://github.com/rillki/tiny-svg) project to generate `setX` methods for all Shapes. Example:

Re: unittest under betterC

2023-06-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work: https://dlang.org/spec/betterc.html#unittests So

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/06/2023 2:25 AM, Mike Parker wrote: On Monday, 5 June 2023 at 14:16:39 UTC, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test The docs say it should work:

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 06/06/2023 2:16 AM, ryuukk_ wrote: In my book this is broken and needs to be fixed, as a user i don't care about under the hood things, it's a you problem, user should be able to unit test If you as the user disable key components required for the language to fully work, its a you

Re: unittest under betterC

2023-06-05 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 5 June 2023 at 11:41:08 UTC, Richard (Rikki) Andrew Cattermole wrote: On 05/06/2023 3:42 PM, ryuukk_ wrote: I don't know how all this works, but the runtime shouldn't know about tests, imagine if you ship a game, and the player can run all the unittests, that doesn't make sense

How do I generate `setX` methods for all private mutable variables in a class?

2023-06-05 Thread Ki Rill via Digitalmars-d-learn
How do I generate `setX` methods for all private mutable variables in my class? Do I need to use `__traits`? I need this for my [tiny-svg](https://github.com/rillki/tiny-svg) project to generate `setX` methods for all Shapes. Example: ```D class Rectangle { private immutable ...;

Re: unittest under betterC

2023-06-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/06/2023 3:42 PM, ryuukk_ wrote: I don't know how all this works, but the runtime shouldn't know about tests, imagine if you ship a game, and the player can run all the unittests, that doesn't make sense Currently that is not possible. When you turn on unittests to be compiled in, that

Re: What's dxml DOMEntity(R) type ?

2023-06-05 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom; ?? xmlRoot; int main() { string xml =

What's dxml DOMEntity(R) type ?

2023-06-05 Thread John Xu via Digitalmars-d-learn
The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work). import dxml.dom; ?? xmlRoot; int main() { string xml = readText("a.xml"); auto dom = parseDOM(xml);

Re: unittest under betterC

2023-06-05 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 03:42:20 UTC, ryuukk_ wrote: [...] I don't know how all this works, ... For what it is worth, running _both_ the above code fragments with: ``` dmd -main -unittest -i -run foo ``` (ie removing the -betterC flag) produces: ``` foo.d(8): [unittest] != Assert