Re: StoppingPolicy.longest never stop?

2011-01-29 Thread tsukikage
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

StoppingPolicy.longest never stop?

2011-01-29 Thread tsukikage
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

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Jonathan M Davis
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

common types + type modifiers

2011-01-29 Thread Ellery Newcomer
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

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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..

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
Well I've updated the tutorial anyway. I just left a note and used an templateImpl companion template.

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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.

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
Wait, why won't this compile?: template foo(int value) { int result; alias result foo; } void main() { writeln( foo!(4) ); }

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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).

pragma(msg,

2011-01-29 Thread Ellery Newcomer
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?

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Trass3r
Save this somewhere or it will be lost here ;)

Re: How can you read and understand the source of *naryFun infunctional.d?

2011-01-29 Thread Andrej Mitrovic
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

Re: How can you read and understand the source of *naryFun infunctional.d?

2011-01-29 Thread Akakima
"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 ]

Re: Nested function declarations

2011-01-29 Thread Andrej Mitrovic
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. :)

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
Fix: So essentially it allows us to use any string of characters instead of "b". I've meant "a" here, not "b".

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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.

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread 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. At first, I started using function templates, because they were the easiest to grasp. Or so I thought. Basically I just used function templates

General unicode category

2011-01-29 Thread Tomek Sowiński
How can I get the general unicode category (Lu, Nd, Pc, etc.) of a dchar? std.uni contains barely anything useful. -- Tomek

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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. :)

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Andrej Mitrovic
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,

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Tomek Sowiński
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

Re: Nested function declarations

2011-01-29 Thread bearophile
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

Re: How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread bearophile
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

Re: std.format example not working

2011-01-29 Thread Akakima
> > 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

How can you read and understand the source of *naryFun in functional.d?

2011-01-29 Thread Tom
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

Re: Nested function declarations

2011-01-29 Thread dennis luehring
They're useful for testing: unittest { int foo(); static assert (is(ReturnType!foo == int)); } and else? is it worth?

Re: Nested function declarations

2011-01-29 Thread Tomek Sowiński
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

Re: Nested function declarations

2011-01-29 Thread bearophile
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

Re: Nested function declarations

2011-01-29 Thread Tomek Sowiński
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

Re: "__gshared static" versus "static __gshared"

2011-01-29 Thread Lars T. Kyllingstad
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

Re: std.format example not working

2011-01-29 Thread Lars T. Kyllingstad
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

Re: Are these (known) bugs?

2011-01-29 Thread biozic
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

"__gshared static" versus "static __gshared"

2011-01-29 Thread %u
Is this a bug? __gshared static i; makes i be thread-local, while static __gshared i; makes it be shared.

Re: Are these (known) bugs?

2011-01-29 Thread biozic
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