Re: Request for a more powerful template specialization feature

2017-07-17 Thread jmh530 via Digitalmars-d
On Monday, 17 July 2017 at 12:29:41 UTC, jmh530 wrote: Forgive me, but what about anySatisfy https://dlang.org/library/std/meta/any_satisfy.html Oh sorry, I see that's a little different.

Re: Request for a more powerful template specialization feature

2017-07-17 Thread jmh530 via Digitalmars-d
On Friday, 14 July 2017 at 19:49:05 UTC, Andrei Alexandrescu wrote: An effective way of improving the state of affairs would be to create a PR that makes the constraint easier to read and write, e.g.: among!(R, double, int) && among!(W, string, char, dchar) In fact it's surprising it

Re: Request for a more powerful template specialization feature

2017-07-15 Thread data pulverizer via Digitalmars-d
On Saturday, 15 July 2017 at 10:34:13 UTC, Enamex wrote: But specializations are quite different from constraints, no? Constraints wouldn't help when the template name is overloaded and passes the constraint checks of several different template implementations; specializations narrow things

Re: Request for a more powerful template specialization feature

2017-07-15 Thread Enamex via Digitalmars-d
On Friday, 14 July 2017 at 19:49:05 UTC, Andrei Alexandrescu wrote: On 7/14/17 2:19 PM, data pulverizer wrote: template Construct(R: Union{double, int}, W: Union{string, char, dchar}) template Construct(R, W) if ((is(R == double) || is(R == int)) && (is(W == string) || is(W == char) ||

Re: Request for a more powerful template specialization feature

2017-07-14 Thread data pulverizer via Digitalmars-d
On Friday, 14 July 2017 at 23:04:48 UTC, Stefan Koch wrote: One important characteristic about constraints, is that they are not bound to types. Also they can from conjunctions and disjunctions. Combined with ctfe they are very flexible and powerful. I do not know how you would do the same

Re: Request for a more powerful template specialization feature

2017-07-14 Thread Stefan Koch via Digitalmars-d
On Friday, 14 July 2017 at 22:49:18 UTC, data pulverizer wrote: On Friday, 14 July 2017 at 22:25:15 UTC, data pulverizer wrote: I am aware that this suggestion touches the language and the compiler - and may significant implications. I would like to know whether this could be done without too

Re: Request for a more powerful template specialization feature

2017-07-14 Thread data pulverizer via Digitalmars-d
On Friday, 14 July 2017 at 22:25:15 UTC, data pulverizer wrote: I am aware that this suggestion touches the language and the compiler - and may significant implications. I would like to know whether this could be done without too much effort and whether it would break anything else? If you

Re: Request for a more powerful template specialization feature

2017-07-14 Thread data pulverizer via Digitalmars-d
On Friday, 14 July 2017 at 18:19:03 UTC, data pulverizer wrote: Dear all, Template specializations are a great feature in D. They allow the programmer to create template specializations but they can also be a powerful way of constraining templates by implementing only the specializations

Re: Request for a more powerful template specialization feature

2017-07-14 Thread Jonathan M Davis via Digitalmars-d
On Friday, July 14, 2017 4:45:10 PM MDT Andrei Alexandrescu via Digitalmars- d wrote: > On 07/14/2017 04:29 PM, Jonathan M Davis via Digitalmars-d wrote: > > I'd guess that you'd use staticIndexOf an check for > > -1 to implement it > > Given that constraints are user-facing, having a forwarding

Re: Request for a more powerful template specialization feature

2017-07-14 Thread Andrei Alexandrescu via Digitalmars-d
On 07/14/2017 04:29 PM, Jonathan M Davis via Digitalmars-d wrote: I'd guess that you'd use staticIndexOf an check for -1 to implement it Given that constraints are user-facing, having a forwarding one-liner may be justifiable. -- Andrei

Re: Request for a more powerful template specialization feature

2017-07-14 Thread Jonathan M Davis via Digitalmars-d
On Friday, July 14, 2017 3:49:05 PM MDT Andrei Alexandrescu via Digitalmars- d wrote: > On 7/14/17 2:19 PM, data pulverizer wrote: > > template Construct(R: Union{double, int}, W: Union{string, char, dchar}) > > template Construct(R, W) > if ((is(R == double) || is(R == int)) > && (is(W ==

Re: Request for a more powerful template specialization feature

2017-07-14 Thread Andrei Alexandrescu via Digitalmars-d
On 7/14/17 2:19 PM, data pulverizer wrote: template Construct(R: Union{double, int}, W: Union{string, char, dchar}) template Construct(R, W) if ((is(R == double) || is(R == int)) && (is(W == string) || is(W == char) || is(W == dchar)) It would be good to get comments and suggestions

Request for a more powerful template specialization feature

2017-07-14 Thread data pulverizer via Digitalmars-d
Dear all, Template specializations are a great feature in D. They allow the programmer to create template specializations but they can also be a powerful way of constraining templates by implementing only the specializations that you need. In contrast template constraints can quickly become