Re: D 2.0

2010-07-25 Thread Peter Alexander
On 25/07/10 5:21 AM, BCS wrote: Hello Trass3r, Is D 2.0 still in alpha? It's in beta. Somewhat. The language? More like an RC. DMD? Beta. And Phobos, I'd say, is still in alpha. Half the simple stuff in there doesn't work, never mind anything that's complex. e.g. Array!int causes a co

Re: D 2.0

2010-07-25 Thread levenshtein
Peter Alexander Wrote: > On 25/07/10 5:21 AM, BCS wrote: > > Hello Trass3r, > > > >>> Is D 2.0 still in alpha? > >>> > >> It's in beta. Somewhat. > >> > > > > The language? More like an RC. DMD? Beta. > > > > And Phobos, I'd say, is still in alpha. Half the simple stuff in there > doesn't work,

Re: Why don't other programming languages have ranges?

2010-07-25 Thread levenshtein
Walter Bright Wrote: > Justin Johansson wrote: > > It sounds like the D PL has invented the range idiom unlike any other PL. > > Pointer programming is deeply embedded into the C++ culture, and iterators > segue > nicely into that culture. For D, however, programming revolves around arrays, >

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Peter Alexander
On 25/07/10 12:11 PM, levenshtein wrote: Walter Bright Wrote: Justin Johansson wrote: It sounds like the D PL has invented the range idiom unlike any other PL. Pointer programming is deeply embedded into the C++ culture, and iterators segue nicely into that culture. For D, however, programmi

Where statement

2010-07-25 Thread bearophile
Some people have proposed the introduction in Python of the 'where' statement. It is quite used in Haskell: printFreqsBySize genome keySize = do ht0 <- htNew keySize ht <- hashGenome genome keySize ht0 l <- htToList ht htFree ht return $ map draw (sortBy so

Re: D 2.0

2010-07-25 Thread Trass3r
The language? More like an RC. Well typedef is to be removed, delete has pretty much been deprecated as I heard. Now they seem to intend to remove scope too (didn't read the topic thoroughly though, I'm sick of all those "remove every single keyword there is in the language" threads)

Re: Where statement

2010-07-25 Thread Trass3r
c = sqrt(a*a + b*b) where: a = retrieve_a() b = retrieve_b() That is equivalent to: c = (retrieve_a() ** 2 + retrieve_b() ** 2) ** 0.5 You immediately give the counter-argument? ^^ Introducing a new keyword + whole new constructs gotta have substantial merit. The 2nd concept is perfe

Re: Why don't other programming languages have ranges?

2010-07-25 Thread levenshtein
Peter Alexander Wrote: > On 25/07/10 12:11 PM, levenshtein wrote: > > Walter Bright Wrote: > > > >> Justin Johansson wrote: > >>> It sounds like the D PL has invented the range idiom unlike any other PL. > >> > >> Pointer programming is deeply embedded into the C++ culture, and iterators > >> seg

Re: Where statement

2010-07-25 Thread bearophile
Trass3r: >You immediately give the counter-argument? ^^< I try to give both pros and cons :-) I think when expressions get even more complex 'where' can help. > Another possibility would probably be the following, but it's not as > compact and nice: > > double c; > { > double a = ret

Re: Conditional purity

2010-07-25 Thread Simen kjaeraas
bearophile wrote: But a bigger problem is that I can't see a way to define a conditionally pure templated function, for example a map() that is pure if the given function pointer is pure, and is not pure otherwise: This is fairly simple currently: template map( alias fn ) { // blah blah b

Re: D 2.0

2010-07-25 Thread bearophile
Trass3r: > Now they seem to intend to remove scope too (didn't read the topic > thoroughly though, I'm sick of all those "remove every single keyword > there is in the language" threads) The Scope!() replacement for scope is not good enough yet: 1) The compiler doesn't test for escapes (as dmd

Re: Where statement

2010-07-25 Thread Michel Fortin
On 2010-07-25 08:33:53 -0400, bearophile said: D lambdas can be multiline, so that's not a problem. But it can be useful to write more readable expressions when they are complex: auto c = sqrt(a*a + b*b) where { auto a = retrieve_a(); auto b = retrieve_b(); } Is this really an improv

Re: Where statement

2010-07-25 Thread Kagamin
bearophile Wrote: > auto c = sqrt(a*a + b*b) where { > auto a = retrieve_a(); > auto b = retrieve_b(); > } the where statement looks as a declaration statement, but scoped block allows arbitrary statements.

Uniform call syntax for operator overloads

2010-07-25 Thread Tomek Sowiński
This doesn't work: int opIndex(int[][] m, uint i, uint j) { return m[i][j]; } unittest { auto m = [[9,8], [2,3]]; auto a = m[0,1]; } It's so by design or by bug? Tomek p.s. Where on D page is uniform call syntax documented? Couldn't find it in functions section.

Re: Conditional purity

2010-07-25 Thread bearophile
Simen kjaeraas: > This is fairly simple currently: > > template map( alias fn ) { // blah blah blah, whatever is necessary here > static if ( isPure!fn ) { > pure map( Range )( Range r ) { ... } > } else { > auto map( Range )( Range r ) { ... } > } > } Do you mean

Re: Uniform call syntax for operator overloads

2010-07-25 Thread bearophile
Tomek S.: > This doesn't work: > int opIndex(int[][] m, uint i, uint j) { return m[i][j]; } That's cute, but in D overloaded operator can be defined inside structs/classes/unions only (this is different from C++). Bye, bearophile

Re: Where statement

2010-07-25 Thread bearophile
Michel Fortin: > Is this really an improvement over using a delegate literal? > > auto c = { > auto a = retrieve_a(); > auto b = retrieve_b(); > return sqrt(a*a + b*b); > }; Cute :-) I have never seen this used in D code. I think you will need

Re: Where statement

2010-07-25 Thread Trass3r
Is this really an improvement over using a delegate literal? auto c = { auto a = retrieve_a(); auto b = retrieve_b(); return sqrt(a*a + b*b); }; Even more clever.

Re: Where statement

2010-07-25 Thread Tomek Sowiński
bearophile wrote: > Some people have proposed the introduction in Python of the 'where' > statement. It is quite used in Haskell: > > printFreqsBySize genome keySize = do > ht0 <- htNew keySize > ht <- hashGenome genome keySize ht0 > l <- htToList ht > htFree ht > return $ map draw (sortBy sortRu

Re: Conditional purity

2010-07-25 Thread Simen kjaeraas
bearophile wrote: Simen kjaeraas: This is fairly simple currently: [snip] Do you mean code like this (this doesn't work yet)? [snip] Yeah. I suggest all people in all D newsgroups, to write code that runs, not uncompilable snippets. All errors in the last Walter's talk can be avoided

Re: D 2.0

2010-07-25 Thread Andrei Alexandrescu
On 07/25/2010 08:22 AM, bearophile wrote: Trass3r: Now they seem to intend to remove scope too (didn't read the topic thoroughly though, I'm sick of all those "remove every single keyword there is in the language" threads) The Scope!() replacement for scope is not good enough yet: 1) The compi

Re: Where statement

2010-07-25 Thread KennyTM~
On Jul 25, 10 21:54, Tomek Sowiński wrote: bearophile wrote: Some people have proposed the introduction in Python of the 'where' statement. It is quite used in Haskell: printFreqsBySize genome keySize = do ht0<- htNew keySize ht<- hashGenome genome keySize ht0 l<- htToList ht htFree ht return

Re: Where statement

2010-07-25 Thread Michel Fortin
On 2010-07-25 09:48:21 -0400, bearophile said: Michel Fortin: Is this really an improvement over using a delegate literal? auto c = { auto a = retrieve_a(); auto b = retrieve_b(); return sqrt(a*a + b*b); }; Cute :-) I have neve

Re: My presentation at Oscon last Thursday

2010-07-25 Thread bearophile
Nice slides, "High Wizardry in the Land of Scala Presentation" by Daniel Spiewak, in pages 4-36 he shows Higher-Kinds and Typeclasses, that can be interesting for D programmers too: http://assets.en.oreilly.com/1/event/45/High%20Wizardry%20in%20the%20Land%20of%20Scala%20Presentation.pdf Bye, be

Re: PNG Lib?

2010-07-25 Thread Eric Poggel
On 7/25/2010 12:26 AM, BCS wrote: Hello dsimcha, Is there any simple PNG lib that's: http://www.dsource.org/projects/scrapple/wiki/LodePngLibrary 1. Written in pure D. I think so. 2. Licensed under the Boost or zlib/libpng license, or some other license that is open-source, non-copyle

Re: PNG Lib?

2010-07-25 Thread dsimcha
== Quote from Eric Poggel (dnewsgr...@yage3d.net)'s article > On 7/25/2010 12:26 AM, BCS wrote: > > Hello dsimcha, > > > >> Is there any simple PNG lib that's: > >> > > > > http://www.dsource.org/projects/scrapple/wiki/LodePngLibrary > > > >> 1. Written in pure D. > >> > > > > I think so. > > > >>

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Don
levenshtein wrote: Peter Alexander Wrote: On 25/07/10 12:11 PM, levenshtein wrote: Walter Bright Wrote: Justin Johansson wrote: It sounds like the D PL has invented the range idiom unlike any other PL. Pointer programming is deeply embedded into the C++ culture, and iterators segue nicely

Re: Why don't other programming languages have ranges?

2010-07-25 Thread dsimcha
== Quote from Don (nos...@nospam.com)'s article > levenshtein wrote: > > Peter Alexander Wrote: > > > >> On 25/07/10 12:11 PM, levenshtein wrote: > >>> Walter Bright Wrote: > >>> > Justin Johansson wrote: > > It sounds like the D PL has invented the range idiom unlike any other > > PL

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Walter Bright
dsimcha wrote: Basically, my take as a practical programmer rather than a theoretical comp-sci researcher is "Who cares if it's been done before if it's not implemented in any practical language?". There's rarely anything truly new in programming. I agree with you that turning an idea into som

Do sorted ranges have any special properties?

2010-07-25 Thread Andrei Alexandrescu
I'm trying to find justifications for keeping assumeSorted and friends within Phobos. Background: assumeSorted(r) where r is some range returns a value that wraps r and clarifies to the caller that it can assume r has been sorted. The obvious use case in Phobos is that find(haystack, needle) c

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Andrei Alexandrescu
On 07/24/2010 08:36 AM, Justin Johansson wrote: It sounds like the D PL has invented the range idiom unlike any other PL. Since the dawn of PL's, which must be about 50 years now since Lisp for example, it is hard to imagine a new PL inventing a completely new idiom as "ranges" seem to purport.

Re: Why don't other programming languages have ranges?

2010-07-25 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > Personally I'm not as much amazed about the time taken, as about the > fact that many people _today_ don't figure what's good about the STL. My > theory (which I expanded in my article On Iteration) is that STL > requires

Re: D's treatment of values versus side-effect free nullary functions

2010-07-25 Thread Jim Balter
"Rainer Deyke" wrote in message news:i2g3oo$vo...@digitalmars.com... On 7/24/2010 15:34, Jim Balter wrote: The point about difficulty goes to why this is not a matter of the halting problem. Even if the halting problem were decidable, that would not help us in the slightest because we are try

Re: Do sorted ranges have any special properties?

2010-07-25 Thread Tomek Sowiński
Andrei Alexandrescu wrote: > I'm trying to find justifications for keeping assumeSorted and friends > within Phobos. Background: assumeSorted(r) where r is some range returns > a value that wraps r and clarifies to the caller that it can assume r > has been sorted. > > The obvious use case in Pho

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Don
Andrei Alexandrescu wrote: On 07/24/2010 08:36 AM, Justin Johansson wrote: It sounds like the D PL has invented the range idiom unlike any other PL. Since the dawn of PL's, which must be about 50 years now since Lisp for example, it is hard to imagine a new PL inventing a completely new idiom a

Re: Do sorted ranges have any special properties?

2010-07-25 Thread Tomek Sowiński
Andrei Alexandrescu wrote: > median -> r[r.length / 2] Generalize to quantile. http://en.wikipedia.org/wiki/Quantile Tomek

Re: D's treatment of values versus side-effect free nullary functions

2010-07-25 Thread Jim Balter
"bearophile" wrote in message news:i2g42t$10c...@digitalmars.com... Rainer Deyke: (A function that performs I/O is obviously not a candidate for CTFE.) I don't fully agree, see this enhancement request of mine: http://d.puremagic.com/issues/show_bug.cgi?id=3952 Bye, bearophile "performs

Re: D 2.0

2010-07-25 Thread Tomek Sowiński
Andrei Alexandrescu wrote: > but scope must go But scope(exit) stays, right?

Re: D 2.0

2010-07-25 Thread BCS
Hello Tomek, Andrei Alexandrescu wrote: but scope must go But scope(exit) stays, right? Totally different thing. :) -- ... <

Re: D's treatment of values versus side-effect free nullary functions

2010-07-25 Thread Jim Balter
"Walter Bright" wrote in message news:i2flvi$4i...@digitalmars.com... Don wrote: Being marked as 'pure' is no guarantee that the function will terminate. Right, and the compiler makes no attempt to check this, either. Of course the compiler makes no attempt to check -- that *would* be the

Re: Are iterators and ranges going to co-exist?

2010-07-25 Thread Jim Balter
"Peter Alexander" wrote in message news:i2eqf1$1i6...@digitalmars.com... On 24/07/10 2:13 PM, Jim Balter wrote: "Peter Alexander" wrote in message news:i27p32$dt...@digitalmars.com... On 21/07/10 6:33 PM, Andrei Alexandrescu wrote: Peter Alexander wrote: == Quote from Walter Bright (news

Re: D's treatment of values versus side-effect free nullary functions

2010-07-25 Thread Don
Jim Balter wrote: "Rainer Deyke" wrote in message news:i2g3oo$vo...@digitalmars.com... On 7/24/2010 15:34, Jim Balter wrote: The point about difficulty goes to why this is not a matter of the halting problem. Even if the halting problem were decidable, that would not help us in the slightest

Re: Uniform call syntax for operator overloads

2010-07-25 Thread Tomek Sowiński
bearophile wrote: > Tomek S.: > >> This doesn't work: >> int opIndex(int[][] m, uint i, uint j) { return m[i][j]; } > > That's cute, but in D overloaded operator can be defined inside > structs/classes/unions only (this is different from C++). Yeah, I know, but why? What bad would happen if ope

Re: D 2.0

2010-07-25 Thread Tomek Sowiński
BCS wrote: > Hello Tomek, > >> Andrei Alexandrescu wrote: >> >>> but scope must go >>> >> But scope(exit) stays, right? >> > > Totally different thing. :) Phew.. He did say "it doesn't deserve a keyword" so I got scared ;)

Re: D 2.0

2010-07-25 Thread Olivier Pisano
Le 25/07/2010 22:40, BCS a écrit : Hello Tomek, Andrei Alexandrescu wrote: but scope must go But scope(exit) stays, right? Totally different thing. :) I must admit I had the same reaction as Tomek while reading Andrei's post :) I am relieved scope (exit|failure|success) is not on the r

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Walter Bright
Andrei Alexandrescu wrote: I strongly believe Walter got the STL and generic programming in general. He might be fuzzy about some minor details, but he is plenty good at plenty other things and always had a good listening ear for the importance of genericity. To be fair, it took me many years

Re: Do sorted ranges have any special properties?

2010-07-25 Thread Lutger
Andrei Alexandrescu wrote: > I'm trying to find justifications for keeping assumeSorted and friends > within Phobos. Background: assumeSorted(r) where r is some range returns > a value that wraps r and clarifies to the caller that it can assume r > has been sorted. > > The obvious use case in Pho

Re: TDPL Errata site is down

2010-07-25 Thread Andrej Mitrovic
I can't compile the stats example, it uses readf() (on page 22), but the compiler complains that it's undefined. I found readf() in the library under std.stream, but importing that won't work. I'm using DMD 2.047. Andrei Alexandrescu Wrote: > Andrej Mitrovic wrote: > > Or, it has some database

Re: Why don't other programming languages have ranges?

2010-07-25 Thread bearophile
Andrei Alexandrescu: > In my humble opinion, the design of Java, C#, and Go is proof > that their authors didn't get the STL. Otherwise, those languages would > be very different. I don't believe you. Among the designers of Java, C# and Go there are people that are both experts and smart. C# de

Re: D's treatment of values versus side-effect free nullary functions

2010-07-25 Thread Don
Jim Balter wrote: "Walter Bright" wrote in message news:i2flvi$4i...@digitalmars.com... Don wrote: Being marked as 'pure' is no guarantee that the function will terminate. Right, and the compiler makes no attempt to check this, either. Of course the compiler makes no attempt to check -- th

library defined typedef

2010-07-25 Thread Trass3r
We had a thread where a suggestion was made for a library defined typedef: enum Type { Independent, Super, Sub, Parallel, } struct Typedef( T, Type type = Type.Sub, T init = T.init, string _f = __FILE__, int _l = __LINE__ ) { T payload = init; static if ( type != Type

Re: library defined typedef

2010-07-25 Thread Trass3r
Probably it's no bad idea to repeat these explanations from Andrei so they don't get lost in the huge original thread: 1. Something that's just like another type yet "parallel" with it. This is good for abstractions that encode different units of measurement that aren't supposed to be mixe

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Don
bearophile wrote: Andrei Alexandrescu: In my humble opinion, the design of Java, C#, and Go is proof that their authors didn't get the STL. Otherwise, those languages would be very different. I don't believe you. Among the designers of Java, C# and Go there are people that are both experts a

Should alias expand visibility?

2010-07-25 Thread Tomek Sowiński
If foo is private but its public alias poo exists, should you be able to use poo? (currently you can't) Tomek

Re: Do sorted ranges have any special properties?

2010-07-25 Thread Philippe Sigaud
> Andrei Alexandrescu wrote: > > > I'm trying to find justifications for keeping assumeSorted and friends > > within Phobos. Background: assumeSorted(r) where r is some range returns > > a value that wraps r and clarifies to the caller that it can assume r > > has been sorted. > > > advantageous

Concurrency

2010-07-25 Thread Graham St Jack
I have been using std.concurrency for a while, and have been very impressed by it. In particular, it was easy to get a complex multi-threaded application going with std.concurrency. The thread-local-storage behaviour of D is really cool too. However, I have had some problems with std.concurren

Re: updated OpenCL headers

2010-07-25 Thread Trass3r
cool, thanks for the updates Made substantial further changes. Which platform are you working on? If it is non-Windows please report whether it works. If you write sample code using cl4d resp. the underlying bindings please also submit to me (via bitbucket).

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Walter Bright
bearophile wrote: Andrei Alexandrescu: In my humble opinion, the design of Java, C#, and Go is proof that their authors didn't get the STL. Otherwise, those languages would be very different. I don't believe you. Among the designers of Java, C# and Go there are people that are both experts and

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Andrei Alexandrescu
On 07/25/2010 04:54 PM, bearophile wrote: Andrei Alexandrescu: In my humble opinion, the design of Java, C#, and Go is proof that their authors didn't get the STL. Otherwise, those languages would be very different. I don't believe you. Among the designers of Java, C# and Go there are people t

Re: Concurrency

2010-07-25 Thread Sean Kelly
Graham St Jack Wrote: > However, I have had some problems with std.concurrency (most of which > I'm sure are already being addressed by Sean). In particular, I wanted a > way to select on multiple file-descriptors so that I could (say) send > commands to a thread that also reads from a blocking

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Sean Kelly
bearophile Wrote: > Andrei Alexandrescu: > > In my humble opinion, the design of Java, C#, and Go is proof > > that their authors didn't get the STL. Otherwise, those languages would > > be very different. > > I don't believe you. Among the designers of Java, C# and Go there are people > that

Re: Why don't other programming languages have ranges?

2010-07-25 Thread Sean Kelly
Sean Kelly Wrote: > So you can do ridiculous things like: > > class A { > void put(List x) {} > } > > class B { > void pass(List x) { > (new A).put(x); > } > } Change that to: class A { void put(List x) {} } class B { void pass(List x) { (new A).put(x);

Re: Should alias expand visibility?

2010-07-25 Thread Nick Sabalausky
"Tomek Sowinski" wrote in message news:i2idhp$2jo...@digitalmars.com... > If foo is private but its public alias poo exists, should you be able to > use > poo? (currently you can't) > > I would think you should be able to (but I'm no authority on the issue).

Re: Concurrency

2010-07-25 Thread Graham St Jack
On 26/07/10 13:48, Sean Kelly wrote: Graham St Jack Wrote: However, I have had some problems with std.concurrency (most of which I'm sure are already being addressed by Sean). In particular, I wanted a way to select on multiple file-descriptors so that I could (say) send commands to a threa