Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-29 Thread Jacob Carlborg via Digitalmars-d-announce

On 2015-09-28 15:03, Adam D. Ruppe wrote:


The tip here is one I've been talking about on irc a little and decided
to write up this time. Using a mixin template to hold the source code of
a thing to be transformed is something I think is kinda cool though
I haven't actually used it in a real project yet. (Actually, I've barely
used UDAs in the real world at all yet. I was so excited for them when
they were new, but it took so long to materialize that I found other
ways to do my stuff and now haven't transitioned!)


This looks pretty cool. Unfortunately the original code needs to be 
contained inside a template :( .


--
/Jacob Carlborg


Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-29 Thread Jacob Carlborg via Digitalmars-d-announce

On 2015-09-29 14:10, Adam D. Ruppe wrote:


Though, I just had an idea on how that might be simplified don't
recreate them, just alias them!



So, conceptually, you'd do something like:


template transformer(alias member) {
 static if(hasUDA!(member, thing))
 mixin(transformed_version_of_member());
 else
 alias member = member;
}
mixin staticMap!(AllMembers!impl_module, transformer);


This looks even more interesting :)

--
/Jacob Carlborg


Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-29 Thread Adam D. Ruppe via Digitalmars-d-announce
On Tuesday, 29 September 2015 at 07:09:35 UTC, Jacob Carlborg 
wrote:
This looks pretty cool. Unfortunately the original code needs 
to be contained inside a template :( .


Yeah. You could put it in a module too (my original plan was to 
write about "module mything_impl; code here" and "module mything; 
mixin magic_from_mything_impl;" but there's a bit more difficulty 
with that and forwarding all members you don't want to transform.


Though, I just had an idea on how that might be simplified 
don't recreate them, just alias them!




So, conceptually, you'd do something like:


template transformer(alias member) {
static if(hasUDA!(member, thing))
mixin(transformed_version_of_member());
else
alias member = member;
}
mixin staticMap!(AllMembers!impl_module, transformer);



So you bring in the original thing via alias in much the same way 
I brought it in via template mixin, then do the rest basically 
the same.



That *should* work and not even be all that much more code. Then 
you don't need to wrap anymore. Though it does still need to be 
in a separate something, whether input module or struct, from the 
output.


Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-28 Thread Atila Neves via Digitalmars-d-announce

On Monday, 28 September 2015 at 13:03:50 UTC, Adam D. Ruppe wrote:
This Week in #Dlang - new bugfix release, Windows driver, 
Azure+vibe tutorial, tip on uda transformations + mixin 
templates


http://arsdnet.net/this-week-in-d/sep-27.html


The tip here is one I've been talking about on irc a little and 
decided to write up this time. Using a mixin template to hold 
the source code of a thing to be transformed is something I 
think is kinda cool though I haven't actually used it in a 
real project yet. (Actually, I've barely used UDAs in the real 
world at all yet. I was so excited for them when they were new, 
but it took so long to materialize that I found other ways to 
do my stuff and now haven't transitioned!)


Really cool trick. I had to run it and look at the output to 
really understand though!


Atila


Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-28 Thread Adam D. Ruppe via Digitalmars-d-announce

On Monday, 28 September 2015 at 13:06:37 UTC, John Colvin wrote:

https://github.com/DlangScience/design/blob/master/design.pdf


BTW there is a plot thing David Simcha did years ago:
http://code.dlang.org/packages/plot2kill

I don't know how good it is though, I've never actually used it.

That page 6 bit is cool too, nice stuff.


This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-28 Thread Adam D. Ruppe via Digitalmars-d-announce
This Week in #Dlang - new bugfix release, Windows driver, 
Azure+vibe tutorial, tip on uda transformations + mixin templates


http://arsdnet.net/this-week-in-d/sep-27.html


The tip here is one I've been talking about on irc a little and 
decided to write up this time. Using a mixin template to hold the 
source code of a thing to be transformed is something I think is 
kinda cool though I haven't actually used it in a real 
project yet. (Actually, I've barely used UDAs in the real world 
at all yet. I was so excited for them when they were new, but it 
took so long to materialize that I found other ways to do my 
stuff and now haven't transitioned!)


Re: This Week in D #37 - forum tutorials and tip on using UDAs

2015-09-28 Thread John Colvin via Digitalmars-d-announce

On Monday, 28 September 2015 at 13:03:50 UTC, Adam D. Ruppe wrote:
The tip here is one I've been talking about on irc a little and 
decided to write up this time. Using a mixin template to hold 
the source code of a thing to be transformed is something I 
think is kinda cool though I haven't actually used it in a 
real project yet. (Actually, I've barely used UDAs in the real 
world at all yet. I was so excited for them when they were new, 
but it took so long to materialize that I found other ways to 
do my stuff and now haven't transitioned!)


Somewhat related to this, see page 6 of what I was working on 
over the weekend: 
https://github.com/DlangScience/design/blob/master/design.pdf