digitalmars.D - [RFC] std.experimental.concepts
- Shammah Chancellor (7/7) Jul 24 2015 I put up a PR for phobos awhile ago for concepts as a library to
- deadalnix (14/21) Jul 24 2015 Doing it as a library would miss a lot of the point of concepts :
- Andrei Alexandrescu (7/27) Jul 25 2015 Agreed, though I would more if "much" were dropped.
- deadalnix (3/6) Jul 25 2015 This is a false dichotomy.
- Andrei Alexandrescu (2/9) Jul 25 2015 We could have both (i.e. add traits to D), but would we want to? -- Andr...
- deadalnix (5/17) Jul 25 2015 Yes. Most template code would benefit from it. For the same
- Tofu Ninja (4/22) Jul 25 2015 Also having both basically destroys walter's augment about it
- Tofu Ninja (2/5) Jul 25 2015 Just noticed I wrote augment instead of argument...
- Andrei Alexandrescu (3/24) Jul 26 2015 I kind of agree with that. Yet it doesn't make a strong case for adding
- Andrei Alexandrescu (3/19) Jul 26 2015 I think we disagree here. It doesn't seem to me that adding features to
- Tofu Ninja (11/37) Jul 26 2015 I think thats valid, D is already too big.
- deadalnix (3/5) Jul 27 2015 I'm all for not adding new stuff.
- Shammah Chancellor (6/31) Jul 29 2015 Agreed, that's why I left the PR alone for so long before someone
- Daniel N (19/26) Jul 25 2015 For those who are on a sugar-rush from Concepts, maybe this is a
- Martin Nowak (5/34) Jul 25 2015 Templates are not bijective, so we'll never be generally able to
- Rikki Cattermole (17/53) Jul 25 2015 ======================================
- Daniel N (5/9) Jul 25 2015 If it only was done for the sake of IFTI, then yes indeed it
- Timon Gehr (3/39) Jul 26 2015 It does not need to be just for identity templates. It can work for all
I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -Shammah
Jul 24 2015
On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahDoing it as a library would miss a lot of the point of concepts : - Compiler can do a fair amount of semantic analysis on template before instantiating them. This work is done once rather than repeating it a every template instantiation. - It allow for much more clearer error messages. Anyone having to maintain some meta code will understand what I'm talking about here. - It make compile time and runtime polymorphism more alike. I do think we'd all agree that Andrei approach to mention template arguments as compile time arguments and go from there is a good move. Concept would be the same move, but for typing. By reusing common language constructs (C++ failed to use that opportunity) for instance.
Jul 24 2015
On 7/24/15 7:13 PM, deadalnix wrote:On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:Interesting.I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahDoing it as a library would miss a lot of the point of concepts : - Compiler can do a fair amount of semantic analysis on template before instantiating them. This work is done once rather than repeating it a every template instantiation.- It allow for much more clearer error messages. Anyone having to maintain some meta code will understand what I'm talking about here.Agreed, though I would more if "much" were dropped.- It make compile time and runtime polymorphism more alike. I do think we'd all agree that Andrei approach to mention template arguments as compile time arguments and go from there is a good move. Concept would be the same move, but for typing. By reusing common language constructs (C++ failed to use that opportunity) for instance.Meh to that. Now stack these advantages against the advantages of template constraints. It's a landslide. Andrei
Jul 25 2015
On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:Now stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 25 2015
On 7/25/15 5:24 PM, deadalnix wrote:On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 25 2015
On Saturday, 25 July 2015 at 22:09:08 UTC, Andrei Alexandrescu wrote:On 7/25/15 5:24 PM, deadalnix wrote:Yes. Most template code would benefit from it. For the same reason that being able to bypass the type system is important, you also would like that most of the code don't.On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 25 2015
On Saturday, 25 July 2015 at 23:25:27 UTC, deadalnix wrote:On Saturday, 25 July 2015 at 22:09:08 UTC, Andrei Alexandrescu wrote:Also having both basically destroys walter's augment about it getting tedious adding constraints at the top level. Having both would mean its opt-in.On 7/25/15 5:24 PM, deadalnix wrote:Yes. Most template code would benefit from it. For the same reason that being able to bypass the type system is important, you also would like that most of the code don't.On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 25 2015
On Sunday, 26 July 2015 at 02:18:34 UTC, Tofu Ninja wrote:Also having both basically destroys walter's augment about it getting tedious adding constraints at the top level. Having both would mean its opt-in.Just noticed I wrote augment instead of argument...
Jul 25 2015
On 7/25/15 10:18 PM, Tofu Ninja wrote:On Saturday, 25 July 2015 at 23:25:27 UTC, deadalnix wrote:I kind of agree with that. Yet it doesn't make a strong case for adding traits to D. I think we shouldn't. -- AndreiOn Saturday, 25 July 2015 at 22:09:08 UTC, Andrei Alexandrescu wrote:Also having both basically destroys walter's augment about it getting tedious adding constraints at the top level. Having both would mean its opt-in.On 7/25/15 5:24 PM, deadalnix wrote:Yes. Most template code would benefit from it. For the same reason that being able to bypass the type system is important, you also would like that most of the code don't.On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 26 2015
On 7/25/15 7:25 PM, deadalnix wrote:On Saturday, 25 July 2015 at 22:09:08 UTC, Andrei Alexandrescu wrote:I think we disagree here. It doesn't seem to me that adding features to D is helpful at this point. -- AndreiOn 7/25/15 5:24 PM, deadalnix wrote:Yes. Most template code would benefit from it. For the same reason that being able to bypass the type system is important, you also would like that most of the code don't.On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 26 2015
On Sunday, 26 July 2015 at 15:24:45 UTC, Andrei Alexandrescu wrote:On 7/25/15 7:25 PM, deadalnix wrote:I think thats valid, D is already too big. I for one would actually be more happy if some things were removed, rather than added. Template specialization and template constraints for one could probable be folded into the same thing. Structs vs Classes is weird. The default GC. Properties also being kinda weird. Lots of little warts. Always hoping for a D3. It has become my HL3 for programming languages, it wont ever happen, but I still hope. And if it did, it would be the most glorious thing ever.On Saturday, 25 July 2015 at 22:09:08 UTC, Andrei Alexandrescu wrote:I think we disagree here. It doesn't seem to me that adding features to D is helpful at this point. -- AndreiOn 7/25/15 5:24 PM, deadalnix wrote:Yes. Most template code would benefit from it. For the same reason that being able to bypass the type system is important, you also would like that most of the code don't.On Saturday, 25 July 2015 at 13:41:22 UTC, Andrei Alexandrescu wrote:We could have both (i.e. add traits to D), but would we want to? -- AndreiNow stack these advantages against the advantages of template constraints. It's a landslide. AndreiThis is a false dichotomy.
Jul 26 2015
On Sunday, 26 July 2015 at 15:24:45 UTC, Andrei Alexandrescu wrote:I think we disagree here. It doesn't seem to me that adding features to D is helpful at this point. -- AndreiI'm all for not adding new stuff.
Jul 27 2015
On Friday, 24 July 2015 at 23:13:25 UTC, deadalnix wrote:On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:Agreed, that's why I left the PR alone for so long before someone pinged me on it. I sort of did it as a POC and didn't quite end up liking the results. The library solution would be okay if it was easier to get diagnostics -- but currently that requires nasty hacks if you looked at the docs.I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahDoing it as a library would miss a lot of the point of concepts : - Compiler can do a fair amount of semantic analysis on template before instantiating them. This work is done once rather than repeating it a every template instantiation. - It allow for much more clearer error messages. Anyone having to maintain some meta code will understand what I'm talking about here. - It make compile time and runtime polymorphism more alike. I do think we'd all agree that Andrei approach to mention template arguments as compile time arguments and go from there is a good move. Concept would be the same move, but for typing. By reusing common language constructs (C++ failed to use that opportunity) for instance.
Jul 29 2015
On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahFor those who are on a sugar-rush from Concepts, maybe this is a fun trick? It almost works, if only IFTI was smart enough to deal with eponymous identity templates. ======================================== int fun(T)(T t) if(is(typeof(T.Put))) { } ======================================== template Putty(T) { static assert(is(typeof(T.Put))); alias Putty = T; } void fun(T)(Putty!T t) { } ========================================
Jul 25 2015
On Saturday, 25 July 2015 at 14:06:05 UTC, Daniel N wrote:On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:Templates are not bijective, so we'll never be generally able to determine T by matching Putty, i.e. 2 different T could have the same Putty!T type. Adding an exception for identity templates seems to be a hack.I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahFor those who are on a sugar-rush from Concepts, maybe this is a fun trick? It almost works, if only IFTI was smart enough to deal with eponymous identity templates. ======================================== int fun(T)(T t) if(is(typeof(T.Put))) { } ======================================== template Putty(T) { static assert(is(typeof(T.Put))); alias Putty = T; } void fun(T)(Putty!T t) { } ========================================
Jul 25 2015
On 26/07/2015 2:14 a.m., Martin Nowak wrote:On Saturday, 25 July 2015 at 14:06:05 UTC, Daniel N wrote:====================================== template Putty(T) { static assert(is(typeof(T.Put))); alias Putty = T; } void fun(!T)(Putty!T t) { } ======================================= void fun(__original_T)(__original_T t) if (is(Putty!__original_T == __original_T)) { } ======================================= Humm, minor rewrite of source by the front end. Definitely would be doable.On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:Templates are not bijective, so we'll never be generally able to determine T by matching Putty, i.e. 2 different T could have the same Putty!T type. Adding an exception for identity templates seems to be a hack.I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahFor those who are on a sugar-rush from Concepts, maybe this is a fun trick? It almost works, if only IFTI was smart enough to deal with eponymous identity templates. ======================================== int fun(T)(T t) if(is(typeof(T.Put))) { } ======================================== template Putty(T) { static assert(is(typeof(T.Put))); alias Putty = T; } void fun(T)(Putty!T t) { } ========================================
Jul 25 2015
On Saturday, 25 July 2015 at 14:14:52 UTC, Martin Nowak wrote:Templates are not bijective, so we'll never be generally able to determine T by matching Putty, i.e. 2 different T could have the same Putty!T type. Adding an exception for identity templates seems to be a hack.If it only was done for the sake of IFTI, then yes indeed it would be a hack, but probably other things as well such as shorter mangling could benefit from the compiler being aware of identity templates.
Jul 25 2015
On 07/25/2015 04:14 PM, Martin Nowak wrote:On Saturday, 25 July 2015 at 14:06:05 UTC, Daniel N wrote:It does not need to be just for identity templates. It can work for all templates not involving non-trivial introspection on the template arguments.On Friday, 24 July 2015 at 19:56:55 UTC, Shammah Chancellor wrote:Templates are not bijective, so we'll never be generally able to determine T by matching Putty, i.e. 2 different T could have the same Putty!T type. Adding an exception for identity templates seems to be a hack.I put up a PR for phobos awhile ago for concepts as a library to kind of start the discussion around concepts. There seemed to be some interest around the PR, so I have rebased it and fixed the formatting. Please take a look: https://github.com/D-Programming-Language/phobos/pull/2627 -ShammahFor those who are on a sugar-rush from Concepts, maybe this is a fun trick? It almost works, if only IFTI was smart enough to deal with eponymous identity templates. ======================================== int fun(T)(T t) if(is(typeof(T.Put))) { } ======================================== template Putty(T) { static assert(is(typeof(T.Put))); alias Putty = T; } void fun(T)(Putty!T t) { } ========================================
Jul 26 2015