tsukikage wrote:
Why this zip not stop after iterated through the longest range? thanks!
import std.stdio, std.range ;
void main() {
auto a = [1,2,3,4] ;
auto b = [6,7,8,9] ;
auto c = "ABCDE" ; // <= longest range here
auto d = "ZYXW" ;
auto CNT = 0 ;
foreach(p; zip(Sto
Why this zip not stop after iterated through the longest range? thanks!
import std.stdio, std.range ;
void main() {
auto a = [1,2,3,4] ;
auto b = [6,7,8,9] ;
auto c = "ABCDE" ; // <= longest range here
auto d = "ZYXW" ;
auto CNT = 0 ;
foreach(p; zip(StoppingPolicy.longes
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
trying to wrap my head around shared,const,immutable (not inout yet,
though someday I'll need to figure out what it's supposed to do)
Currently, dmd doesn't exhibit a lot of consistency wrt the above, so
bear with me as I question every ing thing it does.
my [erroneous?] understanding of
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).
code:
template tct(T1,T2){
string tct = T1.stringof ~ " " ~ T2.stringof ~
typeof(true?T1.init:T2.init).stringof;
}
pragma(msg, tct!(shared(const(int))*, const(int*)));
result:
tct
why?
Save this somewhere or it will be lost here ;)
On 1/29/11, Akakima wrote:
>
> "Andrej Mitrovic"
>
>>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.
>>
>
> That's very good stuff! Well written and very helpful.
>
> May i suggest
"Andrej Mitrovic"
>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.
>
That's very good stuff! Well written and very helpful.
May i suggest you to put that somewhere in a [ maybe new ]
Well, I've never used this actually. If I have some external C
functions I either put them in a separate module and then import them
in when necessary, or wrap them in a struct/class. Whether or not
they're of any use in scoped declarations is beyond me. :)
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
How can I get the general unicode category (Lu, Nd, Pc, etc.) of a dchar?
std.uni contains barely anything useful.
--
Tomek
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
dennis luehring:
> and else? is it worth?
Andrej has shown me another possible purpose:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=24196
Surely they aren't the most useful feature of D language :-) But my guess is
that removing them increases the
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
>
> D1 bugs are still fixed, so bug reports are welcome.
>
> http://d.puremagic.com/issues/
> That's a bug in the documentation, please report. :)
Ok. Will submit a report.
>
> D1 has been declared stable, though, so there is usually no point in
> submitting enhancement requests for it.
>
I t
Hi,
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 functional.d
("https://gi
They're useful for testing:
unittest {
int foo();
static assert (is(ReturnType!foo == int));
}
and else? is it worth?
Tomek Sowiński napisał:
> > What is the purpose of nested function declarations in D? Is it a good idea
> > to just disallow them?
>
> 1. Helper functions don't clutter the namespace.
> 2. Nested functions can access the outer function's stack frame.
OK, I just noticed you asked about declara
Tomek S.
> > What is the purpose of nested function declarations in D? Is it a good idea
> > to just disallow them?
>
> 1. Helper functions don't clutter the namespace.
> 2. Nested functions can access the outer function's stack frame.
My question was not about "nested functions" but about "nes
bearophile napisał:
> What is the purpose of nested function declarations in D? Is it a good idea
> to just disallow them?
1. Helper functions don't clutter the namespace.
2. Nested functions can access the outer function's stack frame.
--
Tomek
On Sat, 29 Jan 2011 08:47:21 +, %u wrote:
> Is this a bug?
>
>__gshared static i;
>
> makes i be thread-local, while
>
>static __gshared i;
>
> makes it be shared.
If that's the case, then it is definitely a bug. The order of attributes
shouldn't matter.
-Lars
On Fri, 28 Jan 2011 23:30:06 -0500, Akakima wrote:
> Firt, i would like to know if you are interested in receiving comments
> an bug reports for DMD V1.
D1 bugs are still fixed, so bug reports are welcome.
http://d.puremagic.com/issues/
D1 has been declared stable, though, so there is usually
Le 28/01/11 22:55, Jonathan M Davis a écrit :
On Friday, January 28, 2011 10:57:58 biozic wrote:
Hi,
I am playing with the to-be-released std.datetime, and encountered these
errors (the last one concerns std.variant, actually), with dmd 2.052
(Mac OS X 10.6):
---
import std.array, std.datetime
Is this a bug?
__gshared static i;
makes i be thread-local, while
static __gshared i;
makes it be shared.
Le 29/01/11 03:51, Jonathan M Davis a écrit :
On Friday 28 January 2011 13:55:03 Jonathan M Davis wrote:
On Friday, January 28, 2011 10:57:58 biozic wrote:
Hi,
I am playing with the to-be-released std.datetime, and encountered these
errors (the last one concerns std.variant, actually), with dm
35 matches
Mail list logo