Flexible Default Function Parameters via structs with Nullable Fields

2019-04-29 Thread Mike Parker via Digitalmars-d-announce
Victor Porton shows how he uses string mixins to generate structs with Nullable fields at compile time to help him pass arbitrary subsets of explicit and default arguments to functions in D. The blog: https://dlang.org/blog/2019/04/29/flexible-default-function-parameters/ Reddit: https://www.r

Re: Flexible Default Function Parameters via structs with Nullable Fields

2019-04-30 Thread JN via Digitalmars-d-announce
On Monday, 29 April 2019 at 13:08:59 UTC, Mike Parker wrote: Victor Porton shows how he uses string mixins to generate structs with Nullable fields at compile time to help him pass arbitrary subsets of explicit and default arguments to functions in D. The blog: https://dlang.org/blog/2019/04/

Re: Flexible Default Function Parameters via structs with Nullable Fields

2019-04-30 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 30 April 2019 at 08:20:29 UTC, JN wrote: It might be nifty by D standards, but for a person not familiar with D Or, as someone familiar with D, I wonder why not just use a plain struct. D allows you to set initial values for struct members plainly. To be frank, I haven't been im

Re: Flexible Default Function Parameters via structs with Nullable Fields

2019-04-30 Thread Simen Kjærås via Digitalmars-d-announce
On Tuesday, 30 April 2019 at 13:10:54 UTC, Adam D. Ruppe wrote: On Tuesday, 30 April 2019 at 08:20:29 UTC, JN wrote: It might be nifty by D standards, but for a person not familiar with D Or, as someone familiar with D, I wonder why not just use a plain struct. D allows you to set initial val

Re: Flexible Default Function Parameters via structs with Nullable Fields

2019-04-30 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 30 April 2019 at 13:44:00 UTC, Simen Kjærås wrote: Now, for the abomination that is callMemberFunctionWithParamsStruct!(t, "f")(combined)... It's just t.f(combined.tupleof) in a bad disguise, and I really can't see the benefit. If you are doing function parameters, there are two k