www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.templatecons ready for comments

reply "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
Hello, All!

std.templatecons: Functional style template constructors.

Documentation:
http://9il.github.io/phobosx/std.templatecons.html

Source:
https://github.com/9il/phobosx/blob/master/std/templatecons.d

Note:
dmd >= 2.64 required

Please destroy!

I am sorry for my English in sources/docs.

Best Regards,
Ilya
Nov 10 2013
next sibling parent "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
D.announce:
http://forum.dlang.org/thread/qwmhsamadhupdlbvasul forum.dlang.org#post-nprfwcjtirujgmbqovnl:40forum.dlang.org
Nov 10 2013
prev sibling next sibling parent reply "David Nadlinger" <code klickverbot.at> writes:
On Sunday, 10 November 2013 at 15:30:29 UTC, Ilya Yaroshenko 
wrote:
 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html
I don't have the time right now to actually review the proposal, but here is a partial application (std.functional.curry is really a misnomer) template that supports skipping certain arguments: https://gist.github.com/klickverbot/1733753 (ConfinedTuple is the same as Pack in std.typetuple). David
Nov 10 2013
parent "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
On Sunday, 10 November 2013 at 16:20:02 UTC, David Nadlinger 
wrote:
 On Sunday, 10 November 2013 at 15:30:29 UTC, Ilya Yaroshenko 
 wrote:
 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html
I don't have the time right now to actually review the proposal, but here is a partial application (std.functional.curry is really a misnomer) template that supports skipping certain arguments: https://gist.github.com/klickverbot/1733753 (ConfinedTuple is the same as Pack in std.typetuple). David
Can I include it instead of Curry?
Nov 10 2013
prev sibling next sibling parent reply "Dicebot" <public dicebot.lv> writes:
(x-post from .announce:)

Had a very quick run-through the provided functionality. Looks
nice and has some of utilities I tend to reinvent in my own code
when doing meta-programming. Though I'd prefer to initiate
creation of nested `std.meta` package and move such stuff there
instead of adding yet another plain module. Also I am trying to
negotiate with Andrei & Walter into deciding std.typetuple fate
which may impact implementation of such module quite a lot :)
Nov 10 2013
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 10 November 2013 at 16:37:30 UTC, Dicebot wrote:
 (x-post from .announce:)

 Had a very quick run-through the provided functionality. Looks
 nice and has some of utilities I tend to reinvent in my own code
 when doing meta-programming. Though I'd prefer to initiate
 creation of nested `std.meta` package and move such stuff there
 instead of adding yet another plain module. Also I am trying to
 negotiate with Andrei & Walter into deciding std.typetuple fate
 which may impact implementation of such module quite a lot :)
I agree. I have a partial (most of the big stuff) port of std.algorithm and std.functional for 'Seq's or whatever we want to call them now, I'll try and whip it up in to a std.meta module with appropriate sub-modules ASAP for discussion/comparison. I am quite pleased with what I've got so far, hopefully I'll have it ready to show during the next week.
Nov 11 2013
parent reply "Dicebot" <public dicebot.lv> writes:
On Monday, 11 November 2013 at 17:35:26 UTC, John Colvin wrote:
 I agree. I have a partial (most of the big stuff) port of 
 std.algorithm and std.functional for 'Seq's or whatever we want 
 to call them now, I'll try and whip it up in to a std.meta 
 module with appropriate sub-modules ASAP for 
 discussion/comparison. I am quite pleased with what I've got so 
 far, hopefully I'll have it ready to show during the next week.
I am proposing to implement superseding package/modules in term of template argument list with no auto-expansion to avoid having two distinct types for that and making signatures a bit more hygienic. Will that be much of a burden? :)
Nov 11 2013
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 11 November 2013 at 20:37:49 UTC, Dicebot wrote:
 On Monday, 11 November 2013 at 17:35:26 UTC, John Colvin wrote:
 I agree. I have a partial (most of the big stuff) port of 
 std.algorithm and std.functional for 'Seq's or whatever we 
 want to call them now, I'll try and whip it up in to a 
 std.meta module with appropriate sub-modules ASAP for 
 discussion/comparison. I am quite pleased with what I've got 
 so far, hopefully I'll have it ready to show during the next 
 week.
I am proposing to implement superseding package/modules in term of template argument list with no auto-expansion to avoid having two distinct types for that and making signatures a bit more hygienic. Will that be much of a burden? :)
My approach is to use two distinct types, Seq and Pack. The combination is actually quite acceptable to use, but I'm open to alternatives. To be honest, I used to feel that auto-expanding tuples were a pain, but once one has decent tools to work with - like I'm trying to create - it isn't much of a problem. Some sort of syntax to create non-expanding tuples, whether as a builtin concept or sugar for a library construct* would be nice, otherwise the already ugly heavy nested parenthesis are made worse by having Pack!(...) everywhere. ';' delimited parameter lists would be one way to do this quite nicely IMO, although there are also a good number of other characters that would be unambiguous in that concept. *preferable, obviously. To answer your question directly: My work uses auto-expanding Seqs quite a bit, but I can't think of anything that couldn't be immediately re-implemented with non-expanding. Without a nice syntax like ';' delimited parameter lists, it would probably be uglier than it currently can be with auto-expanding.
Nov 11 2013
prev sibling next sibling parent reply "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
Is it any reason why Temps[0]!(Arg) and
MetaTemps!(Arg)!(SecondArg) aren't allowed?
Nov 10 2013
parent Timon Gehr <timon.gehr gmx.ch> writes:
On 11/10/2013 05:50 PM, Ilya Yaroshenko wrote:
 Is it any reason why Temps[0]!(Arg) and
No, this is just an arbitrary grammar limitation.
 MetaTemps!(Arg)!(SecondArg) aren't allowed?
! hasn't been assigned an associativity, maybe in order to make disambiguation explicit: (MetaTemps!Arg)!SecondArg MetaTemps!(Arg!SecondArg) In any case. DMD rejects the first case because it parses it as an illegal C-style cast on a logical not expression.
Nov 10 2013
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-11-10 16:30, Ilya Yaroshenko wrote:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d
Don't we already have some of this functionallity, like templateStaticMap and templateStaticIndexOf? -- /Jacob Carlborg
Nov 10 2013
parent "Ilya Yaroshenko" <ilyayaroshenko gmail.com> writes:
On Sunday, 10 November 2013 at 17:54:13 UTC, Jacob Carlborg wrote:
 On 2013-11-10 16:30, Ilya Yaroshenko wrote:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d
Don't we already have some of this functionallity, like templateStaticMap and templateStaticIndexOf?
Yes, for example template Filter(alias pred, TList...) from std.typetuple. But alias templateFilter = ShellOneArg!Filter; is not the same as Filter. It can be used in compose/pipe and others: unittest { import std.complex, std.traits; alias Pipe = templatePipe!(templateFilter!isFloatingPoint, CommonType, Complex); static assert(is(Pipe!(bool[][], immutable float, const double, string) == Complex!double)); }
Nov 10 2013
prev sibling next sibling parent "ilya-stromberg" <ilya-stromberg-2009 yandex.ru> writes:
On Sunday, 10 November 2013 at 15:30:29 UTC, Ilya Yaroshenko 
wrote:
 std.templatecons: Functional style template constructors.
If you want to add `std.templatecons` into Phobos I suggest you to add your code to the Review Queue: http://wiki.dlang.org/Review_Queue If you think that your code is ready, we can start more formal review after Robert Klotzner's `std.signal`. I'm shure Dicebot will help you as Review Manager: http://forum.dlang.org/thread/kiyfunngmuevxjurmjfh forum.dlang.org
Nov 11 2013
prev sibling parent reply Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html -- Денис В. Шеломовский Denis V. Shelomovskij
Nov 11 2013
next sibling parent Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
12.11.2013 0:33, Denis Shelomovskij пишет:
 10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html
Sorry, accidental Ctrl+Enter. So let me continue: As for `std.functional`-like template I can't tell much as the only ones I really use are `unaryFun`/`binaryFun` and its string-to-function abilities which I also need for templates and which I also want to have in Phobos (see [2]). [2] http://denis-sh.bitbucket.org/unstandard/unstd.templates.html -- Денис В. Шеломовский Denis V. Shelomovskij
Nov 11 2013
prev sibling next sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Monday, 11 November 2013 at 20:33:37 UTC, Denis Shelomovskij 
wrote:
 10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html
Can we stop calling this tuples already ? I think one of the thing that everybody can agree upon is that calling that tuples is confusing everybody (including me).
Nov 11 2013
prev sibling parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 11 November 2013 at 20:33:37 UTC, Denis Shelomovskij 
wrote:
 10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html
How would you feel about me cannibalising parts of that for my attempt at making a proper std.meta module? Conveniently it seems that we use similar core ideas, but have implemented disjoint sets of functionality.
Nov 11 2013
parent reply "John Colvin" <john.loughran.colvin gmail.com> writes:
On Monday, 11 November 2013 at 22:18:27 UTC, John Colvin wrote:
 On Monday, 11 November 2013 at 20:33:37 UTC, Denis Shelomovskij 
 wrote:
 10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html
How would you feel about me cannibalising parts of that for my attempt at making a proper std.meta module? Conveniently it seems that we use similar core ideas, but have implemented disjoint sets of functionality.
*somewhat disjoint
Nov 11 2013
parent Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
12.11.2013 2:19, John Colvin пишет:
 On Monday, 11 November 2013 at 22:18:27 UTC, John Colvin wrote:
 On Monday, 11 November 2013 at 20:33:37 UTC, Denis Shelomovskij wrote:
 10.11.2013 19:30, Ilya Yaroshenko пишет:
 Hello, All!

 std.templatecons: Functional style template constructors.

 Documentation:
 http://9il.github.io/phobosx/std.templatecons.html

 Source:
 https://github.com/9il/phobosx/blob/master/std/templatecons.d

 Note:
 dmd >= 2.64 required

 Please destroy!

 I am sorry for my English in sources/docs.

 Best Regards,
 Ilya
No more plain modules, please. Call it `std.meta.<something>`. I'm against of including a few range-like (i.e. like `std.range` and `std.algorithm` stuff) templates like `RepeatExactly`, `templateStaticMap`, and `templateFilter`. First these are generic tuple manipulation templates belong to `std.meta.generictuple` (or how it's called now). Second I'd like to see one-to-one analog of all (most) applicable range operation functions for generic tuples in Phobos by merging in e.g. [1] As for `std.functional`-like template I can't tell much as the only ones http://denis-sh.bitbucket.org/unstandard/unstd.templates.html [1] http://denis-sh.bitbucket.org/unstandard/unstd.generictuple.html
How would you feel about me cannibalising parts of that for my attempt at making a proper std.meta module? Conveniently it seems that we use similar core ideas, but have implemented disjoint sets of functionality.
*somewhat disjoint
Use it as you wish. Also feel free to e-mail me with questions/functionality requests (or open issues for Unstandard project). Just in case you want we also could make `unstd.meta` and then push to Phobos. -- Денис В. Шеломовский Denis V. Shelomovskij
Nov 15 2013