digitalmars.D - Static inheritance (proof of concept)
- Iakh (29/29) Feb 27 2016 There was discussion and proposal to extend D with static
- Chris Wright (7/24) Feb 27 2016 Looks good. I'd prefer to have just the mixin or just the attribute --
- Iakh (12/19) Feb 27 2016 It is hard to pass all params to the mixin such as file, line and
- Chris Wright (2/4) Feb 27 2016 Maybe we need file and line number __traits.
- Iakh (4/8) Feb 27 2016 Nice idea.
- Atila Neves (5/11) Feb 29 2016 It can, yes:
- Iakh (3/15) Feb 29 2016 I'm not familiar with github so i can't see why it was rejected
- Atila Neves (3/22) Feb 29 2016 http://forum.dlang.org/post/tgnxocozkurfvmxqofnn@forum.dlang.org
There was discussion and proposal to extend D with static inheritance: http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf forum.dlang.org But it could be done just with mixins, UDAs and some rewriting of predicates. Exaple: concept!isInputRange() struct Range { mixin checkConcepts; int front() { return 0; } } concept-check ~master: building configuration "application"... source/app.d(73,0): Error: can't test for empty source/app.d(73,0): Error: can't invoke popFront() source/app.d(67,5): Error: static assert "Range is not a concept!(isInputRange)" checker function prototype: bool checkConcept(Flag!"verbose" verbose = No.verbose, string file = "", size_t line = "")() if verbose==false this function could be used in template constraint just to check is template parameter match conditions without printing errors full code: http://dpaste.dzfl.pl/5056ad68c7b4
Feb 27 2016
On Sat, 27 Feb 2016 13:35:30 +0000, Iakh wrote:There was discussion and proposal to extend D with static inheritance: http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf forum.dlang.org But it could be done just with mixins, UDAs and some rewriting of predicates. Exaple: concept!isInputRange() struct Range { mixin checkConcepts; int front() { return 0; } }Looks good. I'd prefer to have just the mixin or just the attribute -- the latter being tricky just now. It'd be just as easy to make it: struct Range { mixin ensureConcept!isInputRange; }
Feb 27 2016
On Saturday, 27 February 2016 at 18:14:25 UTC, Chris Wright wrote:On Sat, 27 Feb 2016 13:35:30 +0000, Iakh wrote: Looks good. I'd prefer to have just the mixin or just the attribute -- the latter being tricky just now.Agree.It'd be just as easy to make it: struct Range { mixin ensureConcept!isInputRange; }It is hard to pass all params to the mixin such as file, line and additional params for concept: concept!(isOutputRange, int)() // isSomething!(T, a, b, c, d, ...) struct Range { mixin checkConcepts; // mixin takes current line and file with default params to do error checking so there is no way to use variadic args (is it?) }
Feb 27 2016
On Sat, 27 Feb 2016 19:45:58 +0000, Iakh wrote:It is hard to pass all params to the mixin such as file, line and additional params for concept:Maybe we need file and line number __traits.
Feb 27 2016
On Saturday, 27 February 2016 at 20:51:22 UTC, Chris Wright wrote:On Sat, 27 Feb 2016 19:45:58 +0000, Iakh wrote:Nice idea. I am also voting for function formatCompilerErrorMessage(text, file, line);It is hard to pass all params to the mixin such as file, line and additional params for concept:Maybe we need file and line number __traits.
Feb 27 2016
On Saturday, 27 February 2016 at 13:35:30 UTC, Iakh wrote:There was discussion and proposal to extend D with static inheritance: http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf forum.dlang.org But it could be done just with mixins, UDAs and some rewriting of predicates.It can, yes: https://github.com/D-Programming-Language/phobos/pull/3677 That went nowhere, hence the DIP. Atila
Feb 29 2016
On Monday, 29 February 2016 at 11:13:18 UTC, Atila Neves wrote:On Saturday, 27 February 2016 at 13:35:30 UTC, Iakh wrote:I'm not familiar with github so i can't see why it was rejected besides auto testing tools (Looks like it's just outdated)There was discussion and proposal to extend D with static inheritance: http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf forum.dlang.org But it could be done just with mixins, UDAs and some rewriting of predicates.It can, yes: https://github.com/D-Programming-Language/phobos/pull/3677 That went nowhere, hence the DIP. Atila
Feb 29 2016
On Monday, 29 February 2016 at 12:31:58 UTC, Iakh wrote:On Monday, 29 February 2016 at 11:13:18 UTC, Atila Neves wrote:http://forum.dlang.org/post/tgnxocozkurfvmxqofnn forum.dlang.org AtilaOn Saturday, 27 February 2016 at 13:35:30 UTC, Iakh wrote:I'm not familiar with github so i can't see why it was rejected besides auto testing tools (Looks like it's just outdated)There was discussion and proposal to extend D with static inheritance: http://forum.dlang.org/thread/jwzxngccuwwizyivpeaf forum.dlang.org But it could be done just with mixins, UDAs and some rewriting of predicates.It can, yes: https://github.com/D-Programming-Language/phobos/pull/3677 That went nowhere, hence the DIP. Atila
Feb 29 2016
On Monday, 29 February 2016 at 13:31:11 UTC, Atila Neves wrote:I didn't get the point. But I could propose one more way to implement it:) Just with template mixins. If concept takes just one template argument (as isInputRange do) then it could be passed just by name, but if there are several args you have to fully instantiate it: struct Range { mixin checkConcept!isInputRange; mixin checkConcept!(isOutputRange!(Range, int)); int front() { return 0; } } This way template mixin could take source line and file to generate better report. First template arg of isOutputRange could be checked is it the same as wrapping type to prevent copy-paste mistakes.I'm not familiar with github so i can't see why it was rejected besides auto testing tools (Looks like it's just outdated)http://forum.dlang.org/post/tgnxocozkurfvmxqofnn forum.dlang.org Atila
Feb 29 2016
On Monday, 29 February 2016 at 13:31:11 UTC, Atila Neves wrote:http://forum.dlang.org/post/tgnxocozkurfvmxqofnn forum.dlang.org AtilaIf you about this: http://forum.dlang.org/post/eejiauievypbfifkyvvo forum.dlang.orgOn Wednesday, 29 July 2015 at 06:05:37 UTC, Kagamin wrote:It could be done without type name repetition: mixin checkConcept!isInputRange; mixin checkConcept!(isOutputRange!(PlaceHolderForThisT, int)); Last one is even more general. It could handle checkers with odd order of parameters.On Tuesday, 28 July 2015 at 13:10:43 UTC, Atila Neves wrote:Writing a generic solution that would work for multiple constraints without code repetition. AtilaI guess, but not easily. I've written template mixins to do that before and it was awkward.What was awkward?
Mar 01 2016