www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Template news (2012+)

reply "Philippe Sigaud" <philippe.sigaud gmail.com> writes:
I've a tutorial on templates here:

https://github.com/PhilippeSigaud/D-templates-tutorial

For the past few days, I transformed the LaTeX files into 
markdown files, which can then generate pdf, epub and html. 
Everything works well, that's cool [1]. I'm following Walter's 
advice from a year ago to provide text for people using 
e-readers/tablets.

This post is not really an announce :) I'm correcting bugs & 
mistakes and seeing the good work the developers put into DMD. 
Several things that were flagged as impossible or buggy when I 
wrote the tutorial a year ago are now possible. Many other things 
have changed on the template front in 2012 and I need help to 
list them all, so as to update my doc.

So, here is my own small list:

- is(Type name = A!(Args), Args...) now exists. The Args... part 
is new.
- the new (a,b) => a+b syntax was introduced
- the eponymous trick works even when other non-eponymous members 
are defined
- error reporting got better
- CTFE got better.
- auto ref?
- __ctfe. I think it arrived just when I wrote the doc. I've now 
used it and it works great!
- UFCS: not a template feature per se, but quite useful in 
conjunction with templates.
- UDA. ditto, except I know zilch about them. But, type & value 
manipulation at compile-time, them I know.


Other changes I'm not sure and that should be tested:

- any change on __LINE__ and __FILE__?
- any change for mixin templates?


Do any of you see missing feature/modification that happened in 
2012(-2013)?


Philippe

[1] I'm using pandoc to convert .md into .pdf, .epub, .mobi and 
.html and it works quite well. Also, its extended markdown syntax 
is nice. Here is an example of a real-world Haskell executable...
Jan 04 2013
next sibling parent reply "Philippe Sigaud" <philippe.sigaud gmail.com> writes:
 So, here is my own small list:

 - is(Type name = A!(Args), Args...) now exists. The Args... 
 part is new.
 - the new (a,b) => a+b syntax was introduced
 - the eponymous trick works even when other non-eponymous 
 members are defined
 - error reporting got better
 - CTFE got better.
 - auto ref?
 - __ctfe. I think it arrived just when I wrote the doc. I've 
 now used it and it works great!
 - UFCS: not a template feature per se, but quite useful in 
 conjunction with templates.
 - UDA. ditto, except I know zilch about them. But, type & value 
 manipulation at compile-time, them I know.

No one can help me complete my list? Has any other thing changed in template-land in 2012?
Jan 05 2013
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
05-Jan-2013 22:58, Philippe Sigaud пишет:
 So, here is my own small list:

 - is(Type name = A!(Args), Args...) now exists. The Args... part is new.
 - the new (a,b) => a+b syntax was introduced
 - the eponymous trick works even when other non-eponymous members are
 defined
 - error reporting got better
 - CTFE got better.
 - auto ref?
 - __ctfe. I think it arrived just when I wrote the doc. I've now used
 it and it works great!
 - UFCS: not a template feature per se, but quite useful in conjunction
 with templates.
 - UDA. ditto, except I know zilch about them. But, type & value
 manipulation at compile-time, them I know.

No one can help me complete my list? Has any other thing changed in template-land in 2012?

Some new traits happened. Not there is a way to peek at function parameter identifiers (!): http://dlang.org/phobos/std_traits.html#.ParameterIdentifierTuple + something else I might forgot in std.traits, it's worth revisiting + isPOD in compiler's __traits -- Dmitry Olshansky
Jan 05 2013
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
06-Jan-2013 00:32, Dmitry Olshansky пишет:
 05-Jan-2013 22:58, Philippe Sigaud пишет:
 So, here is my own small list:

 - is(Type name = A!(Args), Args...) now exists. The Args... part is new.
 - the new (a,b) => a+b syntax was introduced
 - the eponymous trick works even when other non-eponymous members are
 defined
 - error reporting got better
 - CTFE got better.
 - auto ref?
 - __ctfe. I think it arrived just when I wrote the doc. I've now used
 it and it works great!
 - UFCS: not a template feature per se, but quite useful in conjunction
 with templates.
 - UDA. ditto, except I know zilch about them. But, type & value
 manipulation at compile-time, them I know.

No one can help me complete my list? Has any other thing changed in template-land in 2012?

Some new traits happened. Not there is a way to peek at function parameter identifiers (!):

s/Not/Now
 http://dlang.org/phobos/std_traits.html#.ParameterIdentifierTuple
 + something else I might forgot in std.traits, it's worth revisiting
 + isPOD in compiler's __traits

-- Dmitry Olshansky
Jan 05 2013
prev sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
06-Jan-2013 02:12, Philippe Sigaud пишет:
     Some new traits happened.


 I'll have a look.

     Not there is a way to peek at function parameter identifiers (!):
     http://dlang.org/phobos/std___traits.html#.__ParameterIdentifierTuple
<http://dlang.org/phobos/std_traits.html#.ParameterIdentifierTuple>


 I cannot find it.

The link is botched and I dunno why. The usual ctrl+F (command+F) ParameterIndentifier on std.tratis page reveals it for me.
 Hmm, Jacob linked here:

 http://dlang.org/traits.html#parameterNames

 I cannot find it also. Undocumented?


     + something else I might forgot in std.traits, it's worth revisiting


 I don't think I wrote something on std.traits per se (I dealt with
 __traits), but I'll see.

     + isPOD in compiler's __traits


 Ah yes. This one is quite new.

-- Dmitry Olshansky
Jan 06 2013
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--20cf3074da5af27dcc04d291e5ff
Content-Type: text/plain; charset=UTF-8

 Some new traits happened.

I'll have a look.
 Not there is a way to peek at function parameter identifiers (!):
 http://dlang.org/phobos/std_**traits.html#.**ParameterIdentifierTuple<http://dlang.org/phobos/std_traits.html#.ParameterIdentifierTuple>

I cannot find it. Hmm, Jacob linked here: http://dlang.org/traits.html#parameterNames I cannot find it also. Undocumented?
 + something else I might forgot in std.traits, it's worth revisiting

I don't think I wrote something on std.traits per se (I dealt with __traits), but I'll see.
 + isPOD in compiler's __traits

Ah yes. This one is quite new. --20cf3074da5af27dcc04d291e5ff Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi= n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Some new traits h= appened.<br></blockquote><div><br></div><div>I&#39;ll have a look.</div><di= v>=C2=A0</div> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> Not there is a way to peek at function parameter identifiers (!):<br> <a href=3D"http://dlang.org/phobos/std_traits.html#.ParameterIdentifierTupl= e" target=3D"_blank">http://dlang.org/phobos/std_<u></u>traits.html#.<u></u=
ParameterIdentifierTuple</a></blockquote><div><br></div><div>I cannot find=

<div><br></div><div>Hmm, Jacob linked here:</div><div><br></div><div><a hre= f=3D"http://dlang.org/traits.html#parameterNames">http://dlang.org/traits.h= tml#parameterNames</a></div><div><br></div><div>I cannot find it also. Undo= cumented?</div> <div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8= ex;border-left:1px #ccc solid;padding-left:1ex"><br> + something else I might forgot in std.traits, it&#39;s worth revisiting<br=
</blockquote><div><br></div><div>I don&#39;t think I wrote something on st=

=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo= rder-left:1px #ccc solid;padding-left:1ex">+ isPOD in compiler&#39;s __trai= ts</blockquote><div><br></div><div>Ah yes. This one is quite new.</div></di= v> --20cf3074da5af27dcc04d291e5ff--
Jan 05 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 1/5/13, Philippe Sigaud <philippe.sigaud gmail.com> wrote:
 + isPOD in compiler's __traits


Don't use this yet. It's in 2.061 in a half-unusable state and no clear definition of what a POD is. Everything about that trait is uncertain at this time.
Jan 05 2013
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--20cf30334c5ba7d85404d299d279
Content-Type: text/plain; charset=UTF-8

On Sun, Jan 6, 2013 at 5:45 AM, Andrej Mitrovic
<andrej.mitrovich gmail.com>wrote:

 On 1/5/13, Philippe Sigaud <philippe.sigaud gmail.com> wrote:
 + isPOD in compiler's __traits


Don't use this yet. It's in 2.061 in a half-unusable state and no clear definition of what a POD is. Everything about that trait is uncertain at this time.

Duly noted. I saw a pull pass a few days ago (after 2.061), I thought that was it. --20cf30334c5ba7d85404d299d279 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <br><br><div class=3D"gmail_quote">On Sun, Jan 6, 2013 at 5:45 AM, Andrej M= itrovic <span dir=3D"ltr">&lt;<a href=3D"mailto:andrej.mitrovich gmail.com"= target=3D"_blank">andrej.mitrovich gmail.com</a>&gt;</span> wrote:<br><blo= ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c= cc solid;padding-left:1ex"> <div class=3D"im">On 1/5/13, Philippe Sigaud &lt;<a href=3D"mailto:philippe= .sigaud gmail.com">philippe.sigaud gmail.com</a>&gt; wrote:<br> &gt;&gt; + isPOD in compiler&#39;s __traits<br> &gt; Ah yes. This one is quite new.<br> <br> </div>Don&#39;t use this yet. It&#39;s in 2.061 in a half-unusable state an= d no<br> clear definition of what a POD is. Everything about that trait is<br> uncertain at this time.<br></blockquote><div><br></div><div>Duly noted. I s= aw a pull pass a few days ago (after 2.061), I thought that was it.</div><d= iv>=C2=A0</div></div><br> --20cf30334c5ba7d85404d299d279--
Jan 05 2013
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
--047d7bea3e26fa6afa04d2a2bb0b
Content-Type: text/plain; charset=UTF-8

Dmitry:
 The link is botched and I dunno why. The usual ctrl+F (command+F)

I swear I did that! OK, found it, and also ParameterDefaultValues. --047d7bea3e26fa6afa04d2a2bb0b Content-Type: text/html; charset=UTF-8 <div>Dmitry:</div>&gt; The link is botched and I dunno why. The usual ctrl+F (command+F) ParameterIndentifier on std.tratis page reveals it for me.<div><br></div><div>I swear I did that! OK, found it, and also ParameterDefaultValues.</div> <div><br></div><div><br></div> --047d7bea3e26fa6afa04d2a2bb0b--
Jan 06 2013