On 1/30/11, Philippe Sigaud wrote:
> If anyone is interested, I coded a n-args version of
> unaryFun/binaryFun called naryFun. If you use 'a', 'b', ... as args
> names, it can automatically determine the templated function arity.
Is this going in the next release? There's an nary template in
std.
On Sun, Jan 30, 2011 at 12:03, Tom wrote:
> I would like to thank you for that such a great explanation of the
> Template-based
> programming in that unary example. I think it's great you have uploaded that
> to
> the wiki4d, and it's definite will help a lot of people that come from other
> com
I would like to thank you for that such a great explanation of the
Template-based
programming in that unary example. I think it's great you have uploaded that to
the wiki4d, and it's definite will help a lot of people that come from other
common languages background (like C, C# and Python) that do
On Saturday 29 January 2011 16:01:06 Andrej Mitrovic wrote:
> Well now I'm feeling really stupid because apparently this is how it
> *should* work, at least according to the docs.
>
> I'd love to see 'alias symbol this' work even with multiple
> declarations. It'd be nicee..
It's how it should wo
Well now I'm feeling really stupid because apparently this is how it
*should* work, at least according to the docs.
I'd love to see 'alias symbol this' work even with multiple
declarations. It'd be nicee..
Well I've updated the tutorial anyway. I just left a note and used an
templateImpl companion template.
Oh yeah, it's that damn bug where you can't have multiple
declarations, otherwise aliases don't work.
I still don't know if that bug will ever be fixed or if I should add
that to the tutorial.
Wait, why won't this compile?:
template foo(int value)
{
int result;
alias result foo;
}
void main()
{
writeln( foo!(4) );
}
Done: http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial/D2Templates
I've replaced my obvious English mistakes with slightly less obvious
ones. Kinda wish prowiki had a nicer code display though (syntax
highlighting would be nice).
Save this somewhere or it will be lost here ;)
Fix: So essentially it allows us to use any string of characters instead of
"b".
I've meant "a" here, not "b".
Note when I said "But, we *did* pass a valid argument," I was refering
to the original code example I gave at the top where we called
unaryFun for the first time.
Woops, sorry about the missing function definition after the line:
"unaryFun takes the string argument and might create this function:"
This should be maybe:
int unaryFun(int a)
{
return (a & 1) == 0;
}
But that's oversimplification since that instantiation is a function
template itself, not
I hope this gets pasted right, otherwise I'll have to open a freakin' blog. :)
Up until a few months ago, I had no experience with templates whatsoever.
At first, I started using function templates, because they were the
easiest to grasp. Or so I thought. Basically I just used function
templates
P.S. Tom, I'm writing an explanation on how unaryFunImpl works right
now, but it's long. Give me a few more minutes and it'll be done. :)
Andrei, I think there's a lurking bug in unaryFunImpl, on line 53:
enum testAsExpression = "{ ElementType "~parmName
~"; return ("~fun~");}()";
enum testAsStmts = "{"~ElementType.stringof
~" "~parmName~"; "~fun~"}()";
Notice the second enum,
Tom napisał:
> I am learning D for some time. I come from background of C, C# and Python.
> When I saw the ways to use std.algorithem's functions, I have noticed that the
> input lambda's can be writen as strings. Somewhat like the pythonic "exec". I
> went to the source of this feature in functio
Tom:
> The functions unaryFun and binaryFun. Is there a way I can read them and
> understand them easily? or maybe I missed something?
If you learn D well, you will be able to read them. But even if you know D they
aren't easy to read. It's not easy stuff, that's standard-library-grade
material
18 matches
Mail list logo