Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Sunday, April 22, 2012 08:20:13 Jay Norwood wrote: > The comment below worries me a little bit about std.string.icmp. > What if they are two 1MB strings that differ in he first > character? Does it really convert both strings to lower case > before comparing the first character? > > http://dla

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jay Norwood
On Sunday, 22 April 2012 at 02:29:45 UTC, Jonathan M Davis wrote: Regardless of whether it's the Big(O) complexity or the constant factor that's the problem here, clearly there's enough additional overhead that it's causing problems for Jay's particular case. It's also the sort of thing that c

Re: arrays and foreach

2012-04-21 Thread Russel Winder
On Sat, 2012-04-21 at 22:14 -0700, Ali Çehreli wrote: [...] > That part is done: > >http://ddili.org/ders/d.en/hello_world.html As you are emphasizing use of dmd, and the initial programs will all be relatively small scripts, I wonder if using rdmd would be a good move. Shortening the edit--c

Re: arrays and foreach

2012-04-21 Thread Russel Winder
On Sun, 2012-04-22 at 06:59 +0100, Russel Winder wrote: > On Sat, 2012-04-21 at 22:14 -0700, Ali Çehreli wrote: > [...] > > That part is done: > > > >http://ddili.org/ders/d.en/hello_world.html > > Surely "Hello World" shows just a few, and definitely not all, of the > essential concepts of a

Re: arrays and foreach

2012-04-21 Thread Russel Winder
On Sat, 2012-04-21 at 22:14 -0700, Ali Çehreli wrote: [...] > That part is done: > >http://ddili.org/ders/d.en/hello_world.html Surely "Hello World" shows just a few, and definitely not all, of the essential concepts of a programming language. -- Russel.

Re: arrays and foreach

2012-04-21 Thread Ali Çehreli
On 04/18/2012 01:26 AM, Somedude wrote: > For a complete beginner, it's very frustrating to have to read 4 > chapters of fluff, then write the program, and still not knowing how to > run the program. Where is the fun ? I can guarantee that at this point, > 9 out of 10 beginners will drop the read

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Saturday, April 21, 2012 18:26:42 H. S. Teoh wrote: > Actually, I don't think the nested loops affect Big-O complexity at all. > The O(l) complexity (where l = string length) is already inherent in the > string comparison "str < otherStr". Adding more loops over the strings > doesn't change the

Re: toLower() and Unicode are incomplete was: Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Saturday, April 21, 2012 18:43:23 Ali Çehreli wrote: > On 04/21/2012 04:24 PM, Jay Norwood wrote: > > While playing with sorting the unzip archive entries I tried use of the > > last example in http://dlang.org/phobos/std_algorithm.html#sort > > > > std.algorithm.sort!("toLower(a.name) < >

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Sunday, April 22, 2012 03:47:30 Jay Norwood wrote: > On Saturday, 21 April 2012 at 23:54:26 UTC, Jonathan M Davis > > wrote: > > Yeah. toLower would be called on both strings on _every_ > > compare. And since > > that involves a loop, that would make the overall call to sort > > an order of > >

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jay Norwood
On Saturday, 21 April 2012 at 23:54:26 UTC, Jonathan M Davis wrote: Yeah. toLower would be called on both strings on _every_ compare. And since that involves a loop, that would make the overall call to sort an order of magnitude worse than if you didn't call toLower at all. I'm not sure if it's

toLower() and Unicode are incomplete was: Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Ali Çehreli
On 04/21/2012 04:24 PM, Jay Norwood wrote: > While playing with sorting the unzip archive entries I tried use of the > last example in http://dlang.org/phobos/std_algorithm.html#sort > > std.algorithm.sort!("toLower(a.name) < > toLower(b.name)",std.algorithm.SwapStrategy.stable)(entries); Stealin

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread H. S. Teoh
On Sat, Apr 21, 2012 at 05:45:35PM -0700, Jonathan M Davis wrote: > On Saturday, April 21, 2012 20:36:18 bearophile wrote: > > Jonathan M Davis: > > > I'm not sure if it's an order of magnitude worse than your > > > solution though, since it's been a while since I studied Big(O) > > > notation (doi

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Saturday, April 21, 2012 20:36:18 bearophile wrote: > Jonathan M Davis: > > I'm not sure if it's > > an order of magnitude worse than your solution though, since it's been a > > while since I studied Big(O) notation (doing the conversion only once is > > still more expensive than not converting,

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread bearophile
Jonathan M Davis: > I'm not sure if it's > an order of magnitude worse than your solution though, since it's been a > while > since I studied Big(O) notation (doing the conversion only once is still more > expensive than not converting, but I'm not sure how much more expensive - it > might co

Regarding the more precise GC

2012-04-21 Thread bearophile
In the main D newsgroup I have seen the two recent threads regarding a more precise GC in D. I have two questions about that, that seem more fit for D.learn. 1) I have not fully understood the performance and memory implications of the more precise GC. In the thread I think I've seen a memory

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
I just pushed an update to git with a few changes people have suggested. I removed one of the old opAssigns to keep a static type check. Added assumeNotNull and checkNotNull as entry points. Made the data member private. I think that's closer to what everyone wants.

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jonathan M Davis
On Sunday, April 22, 2012 01:24:56 Jay Norwood wrote: > While playing with sorting the unzip archive entries I tried use > of the last example in > http://dlang.org/phobos/std_algorithm.html#sort > > std.algorithm.sort!("toLower(a.name) < > toLower(b.name)",std.algorithm.SwapStrategy.stable)(entri

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
On Saturday, 21 April 2012 at 23:26:04 UTC, bearophile wrote: I think before putting something in Phobos it's generally better to have used it in Real Code for some time. I agree, but this comes up a LOT on the newsgroup, so I figure we need to get something up there to point people to. I am n

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
On Saturday, 21 April 2012 at 23:27:38 UTC, Namespace wrote: But one thing: i missed there an invariant which check if t is null. If i write "f.t = null;" no error occured. Don't do that! Maybe I should make t private...

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
On Saturday, 21 April 2012 at 23:18:40 UTC, Namespace wrote: I see you're right. Great! But it is only on git hub and not in the standard typecons header in 2.059, right? Right, I missed the deadline for that.

Re: Keyword to avoid not null references

2012-04-21 Thread Namespace
On Saturday, 21 April 2012 at 23:18:40 UTC, Namespace wrote: I see you're right. Great! But it is only on git hub and not in the standard typecons header in 2.059, right? But one thing: i missed there an invariant which check if t is null. If i write "f.t = null;" no error occured.

Re: Keyword to avoid not null references

2012-04-21 Thread bearophile
Adam D. Ruppe: We can do not null in the library reasonably well. I have a basic one in github: https://github.com/D-Programming-Language/phobos/pull/477 It says: I haven't actually used any NotNull in practice, but from the attached tests, it looks like it will work well - hence, the pull

avoid toLower in std.algorithm.sort compare alias

2012-04-21 Thread Jay Norwood
While playing with sorting the unzip archive entries I tried use of the last example in http://dlang.org/phobos/std_algorithm.html#sort std.algorithm.sort!("toLower(a.name) < toLower(b.name)",std.algorithm.SwapStrategy.stable)(entries); It was terribly slow for sorting the 34k entries in my

Re: Keyword to avoid not null references

2012-04-21 Thread Namespace
I see you're right. Great! But it is only on git hub and not in the standard typecons header in 2.059, right?

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
On Saturday, 21 April 2012 at 22:48:27 UTC, Namespace wrote: So every time i want to avoid null references i have to write "NotNull!(Foo) f" (or better, because it's a struct: "ref NotNull!(Foo) f")? It is already a reference! Otherwise, it couldn't be null anyway. But, yes, you'd write NotNu

Re: Keyword to avoid not null references

2012-04-21 Thread Timon Gehr
On 04/22/2012 12:48 AM, Namespace wrote: On Saturday, 21 April 2012 at 22:18:02 UTC, Adam D. Ruppe wrote: We can do not null in the library reasonably well. I have a basic one in github: https://github.com/D-Programming-Language/phobos/pull/477 So every time i want to avoid null references i

Re: Keyword to avoid not null references

2012-04-21 Thread Timon Gehr
On 04/21/2012 11:40 PM, Namespace wrote: My question is, why D hasn't got an explicit Keyword to check at compile time for non null references? It shouldn't be a special keyword. If the compiler can do the necessary analysis to actually enforce that the reference cannot hold a null reference,

Re: Keyword to avoid not null references

2012-04-21 Thread Namespace
On Saturday, 21 April 2012 at 22:18:02 UTC, Adam D. Ruppe wrote: We can do not null in the library reasonably well. I have a basic one in github: https://github.com/D-Programming-Language/phobos/pull/477 So every time i want to avoid null references i have to write "NotNull!(Foo) f" (or bette

using ntfs write_through option to create an efficient unzipped layout

2012-04-21 Thread Jay Norwood
Below are measured times on operations on an unzipped 2GB layout. My observation is that use of a slightly modified version of std.file.write for the creation of the unzipped files results in a folder that is much more efficient for sequential file system operations. In particular, the ntfs rm

Re: Question about arrays

2012-04-21 Thread Andrej Mitrovic
On 4/22/12, Stephen Jones wrote: > My C programming lies in cobwebs but from memory an array was a > pointer to the zeroth index of a set of uniformly sized chunks of > memory. I am perplexed to find that in D a call to an array (of > float vertices for example) cannot be accomplished by handing &

Re: Question about arrays

2012-04-21 Thread Ali Çehreli
On 04/21/2012 03:05 PM, Stephen Jones wrote: > My C programming lies in cobwebs but from memory an array was a pointer > to the zeroth index of a set of uniformly sized chunks of memory. Yes and no. :) What you are describing is the feature where an array decays to what you describe. But there

Re: Derelict2 openGL3 issues

2012-04-21 Thread David
Am 21.04.2012 23:49, schrieb Stephen Jones: On Saturday, 21 April 2012 at 11:02:51 UTC, David wrote: glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);//is this right casting a void pointer for 0 offset? I do it like this: cast(void*)OFFSET; e.g. cast(void*)12; Thankyou David. Just to

Re: Keyword to avoid not null references

2012-04-21 Thread Adam D. Ruppe
We can do not null in the library reasonably well. I have a basic one in github: https://github.com/D-Programming-Language/phobos/pull/477

Re: Broken link to D Programming Language Specification

2012-04-21 Thread Jakob Ovrum
On Saturday, 21 April 2012 at 20:56:27 UTC, Kamil Slowikowski wrote: This link fails to load for me: http://digitalmars.com/d/2.0/dlangspec.mobi I'd really like a copy for myself. Can I get it elsewhere? The eBook is a compilation of the pages on dlang.org, which sources are hosted on Github

Question about arrays

2012-04-21 Thread Stephen Jones
My C programming lies in cobwebs but from memory an array was a pointer to the zeroth index of a set of uniformly sized chunks of memory. I am perplexed to find that in D a call to an array (of float vertices for example) cannot be accomplished by handing &v to functions that need the zeroth in

Re: Docs: Section on local variables

2012-04-21 Thread Jonathan M Davis
On Saturday, April 21, 2012 18:26:52 Andrej Mitrovic wrote: > On 4/21/12, H. S. Teoh wrote: > > It would be a major pain if every > > single time you need to temporarily suppress a section of code, you also > > have to hunt down every last stray variable that's now no longer > > referenced in the

Re: Derelict2 openGL3 issues

2012-04-21 Thread Stephen Jones
On Saturday, 21 April 2012 at 11:02:51 UTC, David wrote: glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);//is this right casting a void pointer for 0 offset? I do it like this: cast(void*)OFFSET; e.g. cast(void*)12; Thankyou David. Just to complete the code for those who follow: it

Keyword to avoid not null references

2012-04-21 Thread Namespace
My question is, why D hasn't got an explicit Keyword to check at compile time for non null references? I understand that such check when they're implicit and refer to all objects they slow down the programm, but why doesn't exist an explicit keyword like @ref or a simple '@' before the Object na

Re: Nested RegEx

2012-04-21 Thread Dmitry Olshansky
On 21.04.2012 22:46, H. S. Teoh wrote: On Sat, Apr 21, 2012 at 09:41:18PM +0400, Dmitry Olshansky wrote: On 21.04.2012 21:24, nrgyzer wrote: Hi guys, I'm trying to use std.regex to parse a string like the following: string myString = "preOuter {if condition1} content1 {if condition2} content2

Re: Operator overloading

2012-04-21 Thread Xan
Thank you very very much, Dmitry. Now all it's fine! Xan. On Friday, 20 April 2012 at 19:51:40 UTC, Dmitry Olshansky wrote: On 20.04.2012 23:33, Xan wrote: Yes, you're wright. So in. But what fails? I reveice these errors and I have no idea what fails! Sorry, the errors are: $ gdmd-4.6 a

Re: Nested RegEx

2012-04-21 Thread H. S. Teoh
On Sat, Apr 21, 2012 at 09:41:18PM +0400, Dmitry Olshansky wrote: > On 21.04.2012 21:24, nrgyzer wrote: > >Hi guys, > > > >I'm trying to use std.regex to parse a string like the following: > > > >string myString = "preOuter {if condition1} content1 {if condition2} content2 > >{elseif condition3} co

Re: Docs: Section on local variables

2012-04-21 Thread H. S. Teoh
On Sat, Apr 21, 2012 at 06:26:52PM +0200, Andrej Mitrovic wrote: > On 4/21/12, H. S. Teoh wrote: > > It would be a major pain if every single time you need to > > temporarily suppress a section of code, you also have to hunt down > > every last stray variable that's now no longer referenced in the

Re: Docs: Section on local variables

2012-04-21 Thread H. S. Teoh
On Sat, Apr 21, 2012 at 06:42:06PM +0200, bearophile wrote: > H. S. Teoh: > > >>Why do you want to be able to declare local variables and then > >>never use them? > >[...] > > > >It happens a lot when you're debugging code (temporarily comment out > >some stuff for testing purposes). It would be a

Re: variadic mixin templates and other stuff

2012-04-21 Thread Martin Drasar
On 20.4.2012 19:00, John Chapman wrote: > On Friday, 20 April 2012 at 14:57:03 UTC, Martin Drasar wrote: >> On 20.4.2012 16:09, Timon Gehr wrote: >> >> I tried but it still refuses to compile: >> >> string interfaceGuid(string ifaceName) >> { >> return ifaceName ~ "Guid"; >> } >> >> mixin templat

Re: Nested RegEx

2012-04-21 Thread Dmitry Olshansky
On 21.04.2012 21:24, nrgyzer wrote: Hi guys, I'm trying to use std.regex to parse a string like the following: string myString = "preOuter {if condition1} content1 {if condition2} content2 {elseif condition3} content3 {else}any other content{/if}{/if} postOuter"; Simply put pure regex is inc

Nested RegEx

2012-04-21 Thread nrgyzer
Hi guys, I'm trying to use std.regex to parse a string like the following: string myString = "preOuter {if condition1} content1 {if condition2} content2 {elseif condition3} content3 {else}any other content{/if}{/if} postOuter"; Is there any chance to use std.regex to parse the string above? I cu

Re: Docs: Section on local variables

2012-04-21 Thread bearophile
H. S. Teoh: Why do you want to be able to declare local variables and then never use them? [...] It happens a lot when you're debugging code (temporarily comment out some stuff for testing purposes). It would be a major pain if every single time you need to temporarily suppress a section of

Re: Docs: Section on local variables

2012-04-21 Thread Andrej Mitrovic
On 4/21/12, H. S. Teoh wrote: > It would be a major pain if every > single time you need to temporarily suppress a section of code, you also > have to hunt down every last stray variable that's now no longer > referenced in the function and comment them out as well. Next thing you know the compil

Re: BigInt Bug or just me?

2012-04-21 Thread Jordi Sayol
Al 21/04/12 16:42, En/na Tyro[17] ha escrit: > Actually, in that case it only happens when compiling to 64-bit. > > Note: comb1(BigInt(40), BigInt(20))/2; The the BigInt version is > being divided by two (on MAC OS X) in order to yield the > correct result. > You are right, sorry. My test was d

Re: Docs: Section on local variables

2012-04-21 Thread H. S. Teoh
On Sat, Apr 21, 2012 at 01:03:13PM +0100, Stewart Gordon wrote: > On 20/04/2012 01:53, Andrej Mitrovic wrote: [...] > >It is an error to declare a local variable that is never referred to. > >Dead variables, like anachronistic dead code, are just a source of > >confusion for maintenance programmers

Re: BigInt Bug or just me?

2012-04-21 Thread Tyro[17]
On Saturday, 21 April 2012 at 14:30:49 UTC, Jordi Sayol wrote: Al 21/04/12 16:07, En/na Tyro[17] ha escrit: Why does the following implementation of the binomial coefficient yield two different answers? Only happens when compiling to 32-bit. 32-bit: (40 20) = 137846528820 (40 20) = 689232

Re: BigInt Bug or just me?

2012-04-21 Thread Jordi Sayol
Al 21/04/12 16:07, En/na Tyro[17] ha escrit: > Why does the following implementation of the binomial coefficient yield two > different answers? > Only happens when compiling to 32-bit. 32-bit: (40 20) = 137846528820 (40 20) = 68923264410 64-bit: (40 20) = 137846528820 (40 20) = 13784652882

BigInt Bug or just me?

2012-04-21 Thread Tyro[17]
Why does the following implementation of the binomial coefficient yield two different answers? import std.stdio, std.bigint; void main() { // Correct result when using long writeln("(40 20) = ", binomial(40L, 20L)); // 2 times the expected result when using BigInt writeln("(40

Re: Docs: Section on local variables

2012-04-21 Thread Stewart Gordon
On 20/04/2012 01:53, Andrej Mitrovic wrote: Can I remove this section from the D docs, in functions? : " Local Variables It is an error to use a local variable without first assigning it a value. The implementation may not always be able to detect these cases. Other language compilers sometimes

Re: Formatting dates in std.datetime?

2012-04-21 Thread Stewart Gordon
On 20/04/2012 21:29, H. S. Teoh wrote: Is there a way to format std.datetime.Date objects with a custom format string? My utility library has a datetime module with a custom formatting facility. http://pr.stewartsplace.org.uk/d/sutil/ The format string scheme is one of my own design, using re

Re: Derelict2 openGL3 issues

2012-04-21 Thread David
Am 21.04.2012 01:16, schrieb Stephen Jones: glBufferData(GL_ARRAY_BUFFER, v.length * GL_FLOAT.sizeof, &v, GL_STATIC_DRAW); Error spotted! This has to be: glBufferData(GL_ARRAY_BUFFER, v.length * float.sizeof, v.ptr, GL_STATIC_DRAW); float.sizeof is just cosmetic, the important thing

Re: Derelict2 openGL3 issues

2012-04-21 Thread David
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, null);//is this right casting a void pointer for 0 offset? I do it like this: cast(void*)OFFSET; e.g. cast(void*)12;

Re: Equivalents to policy classes in D

2012-04-21 Thread Joseph Rushton Wakeling
On 20/04/12 04:36, Joseph Rushton Wakeling wrote: On 03/04/12 02:24, Cristi Cobzarenco wrote: Mixins templates would be the answer: OK, I've had a go at writing up some mixin template-based policy code of my own. Oh, fun. You can even have the constructor provided by a template mixin ... !