Re: Dynamic length string array at compile time?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/23 4:38 PM, Dany12L wrote: On Tuesday, 6 June 2023 at 14:26:01 UTC, Steven Schveighoffer wrote: On 6/5/23 11:45 AM, Dany12L wrote: Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably

Re: unittest under betterC

2023-06-06 Thread DLearner via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:22:45 UTC, Ernesto Castellotti wrote: [...] It's not so easy to deal automatically in case of multiple modules _multiple modules_ The following code, in a batch (.bat) file, works for me: ``` @echo off :loop if [%1]==[] goto loopexit type .\%1.d > .\__temp_%1.d

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

2023-06-06 Thread Ki Rill via Digitalmars-d-learn
On Monday, 5 June 2023 at 18:54:30 UTC, cc wrote: [...] Is there a way to check for mutability as well? I have both immutable and mutable fields. I would like to generate setters for mutable fields only.

Cannot convert expression of a SubType's sub type to the parent SubType on return

2023-06-06 Thread Josh Holtrop via Digitalmars-d-learn
I am trying to use std.sumtype which seems to be just what I need for some functions that can return various types of errors with parameters or a success value with different parameters. In this test I get a compilation error with ldc2: ```d import std.stdio; import std.sumtype; struct Error

Re: Dynamic length string array at compile time?

2023-06-06 Thread Dany12L via Digitalmars-d-learn
On Tuesday, 6 June 2023 at 14:26:01 UTC, Steven Schveighoffer wrote: On 6/5/23 11:45 AM, Dany12L wrote: Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably the reason nobody answered the

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

2023-06-06 Thread Ali Çehreli via Digitalmars-d-learn
On 6/6/23 09:13, Basile B. wrote: > yeah I know that opDispatch is disliked because it is tried in a SFINAE > fashion, as citicized by Adam. But on the other side it's the best opover. I like how it helped in my current project: user.someShellCommand("-foo", "-bar"); opDispatch makes a

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

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/23 12:15 PM, Ferhat Kurtulmuş wrote: On Tuesday, 6 June 2023 at 14:16:37 UTC, Steven Schveighoffer wrote: In general, the easiset thing to do is use typeof, though it's not always pretty (and not always obvious how to write it). However, it's required for voldemort types. ```d

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

2023-06-06 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Tuesday, 6 June 2023 at 14:16:37 UTC, Steven Schveighoffer wrote: On 6/5/23 6:43 AM, Ferhat Kurtulmuş wrote: On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: [...] ```d import dxml.dom; import std.stdio;     DOMEntity!string xmlRoot;     int main()     {     string xml = "";

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

2023-06-06 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 6 June 2023 at 14:23:59 UTC, Steven Schveighoffer wrote: On 6/5/23 11:33 AM, Basile B. wrote: [...] Ugh, don't do it that way. Always give opDispatch a template constraint or it will suck to use. Also, given the problem constraints, you can build the method automatically using

Re: how to skip empty field in csvReader?

2023-06-06 Thread mw via Digitalmars-d-learn
On Tuesday, 6 June 2023 at 14:18:25 UTC, Steven Schveighoffer wrote: On 6/6/23 1:09 AM, mw wrote: Is there a way to tell csvReader to skip such empty fields? What I have done is specify that it's a string, and then handle the conversion myself. The std library need to be enhanced to skip

Re: Dynamic length string array at compile time?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/23 11:45 AM, Dany12L wrote: Hi, I'd be interested to know if it's possible to have a dynamic length array containing strings generated at compile time. Sure. Just do it. Probably the reason nobody answered the question yet is that it trivially works if you try it :) Unless you did

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

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/23 11:33 AM, Basile B. wrote: 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

Re: how to skip empty field in csvReader?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/23 1:09 AM, mw wrote: Is there a way to tell csvReader to skip such empty fields? What I have done is specify that it's a string, and then handle the conversion myself. Possibly it can use Nullable, but I'm not sure. Or, is there another CSV reader library with this functionality

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

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/23 6:43 AM, 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;     ?? xmlRoot;    

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

2023-06-06 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 June 2023 at 15:28:34 UTC, Paul Backus wrote: Is there a reason you can't just make these fields `public`? My bet is that OP actually wants to generate something like ```d void setStrokeWidth(uint value) { if (value = strokeWidth) return; strokeWidth = value;

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

2023-06-06 Thread Basile B. via Digitalmars-d-learn
On Monday, 5 June 2023 at 15:28:34 UTC, Paul Backus wrote: Is there a reason you can't just make these fields `public`? My bet is that OP actually wants to generate something like ```d void setStrokeWidth(uint value) { if (value = strokeWidth) return; strokeWidth = value;