Re: collectException range violation

2013-02-19 Thread monarch_dodra
On Wednesday, 20 February 2013 at 01:32:10 UTC, cal wrote: On Wednesday, 20 February 2013 at 01:19:54 UTC, Ali Çehreli wrote: The example is wrong. a[4] throws an Error (not Exception) but collectException catches Exception by default. Additionally, the example is doing something that is reco

Re: collectException range violation

2013-02-19 Thread cal
On Wednesday, 20 February 2013 at 01:19:54 UTC, Ali Çehreli wrote: The example is wrong. a[4] throws an Error (not Exception) but collectException catches Exception by default. Additionally, the example is doing something that is recommended against: Catching Error or a descendent of it. Sti

Re: collectException range violation

2013-02-19 Thread Ali Çehreli
On 02/19/2013 04:38 PM, cal wrote: > Is this example from the docs still meant to work? > > int[] a = new int[3]; > int b; > assert(collectException(a[4], b)); The example is wrong. a[4] throws an Error (not Exception) but collectException catches Exception by default. Additionally, the exampl

on DDoc macros: a small problem

2013-02-19 Thread Charles Hixson
I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN Note:))) * Todo = ToDo: $0 * Em = $(B$(BLUE $0)) * DoNotUse = $(B Do Not Use $0) */ Why do I need that DoNotUse macro to terminate the Em macro? If I don't include it, the Em macro picks up the first line of

collectException range violation

2013-02-19 Thread cal
Is this example from the docs still meant to work? int[] a = new int[3]; int b; assert(collectException(a[4], b));

Re: How to dynamically alias a struct to a byte array?

2013-02-19 Thread Charles Hixson
On 02/17/2013 09:32 PM, Ali Çehreli wrote: On 02/17/2013 12:12 PM, jerro wrote: > You don't need to cast it each time, you can do something like: > > auto structPointer = cast(MyStruct*) byteArray.ptr; And that pointer can be converted to a D slice: MyStruct[] slice = structPointer[0..numbe

Re: A little of coordination for Rosettacode

2013-02-19 Thread bearophile
Jos van Uden: The chirality of the given output on Langtons ant doesn't match what the code produces. OK. I have changed the first entry. Bye, bearophile

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
monarch_dodra wrote: In theory, there should be no reproducibility breakage, as the generators themselves will not be changed (they are _strictly_ modeled after boosts' (the ones we have anyways)). Indeed, I just looked at Boost and C++11 implementations, and they currently have these divisio

Re: What is the use case of RandomCover?

2013-02-19 Thread bearophile
Ivan Kazmenko: Still, the current implementation uses divisions (which is slow on most CPUs), and for a good source of random bits such as MT19937, the implementation which repeatedly gets exactly core.bitop.bsr(LIMIT)+1 bits until the result is in [0, LIMIT) may be faster. Is this to repor

Re: D-DLLs & Python

2013-02-19 Thread John Colvin
On Tuesday, 19 February 2013 at 19:06:47 UTC, jerro wrote: D doesn't use null termination for it's strings, strings are immutable(char)[]. You can form a D slice from a pointer by going slice = ptr[0..length] where length is the length of the array the pointer represents. You can't just take a

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
On a side note, as D also uses MT19937 as the main RNG, random2 designers may want to address the same accuracy issue which Python did. More on that topic here: http://bugs.python.org/issue9025 Sorry for replying to myself again, but the abovementioned accuracy issue is not about MT19937. I

Re: What is the use case of RandomCover?

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 21:54:54 UTC, Ivan Kazmenko wrote: monarch_dodra wrote: void main() { uint[5] arr1; arr1[].fill(rndGen); uint[5] arr2; arr2[].fill(rndGen); writeln("arr1: ", arr1[]); writeln("arr1: ", arr2[]); } // arr1: [3622200385, 2579361262, 3208046123,

Re: A little of coordination for Rosettacode

2013-02-19 Thread Jos van Uden
The chirality of the given output on Langtons ant doesn't match what the code produces. (That's because somebody changed it a while ago). See also the talk page. http://rosettacode.org/wiki/Langton%27s_ant#D

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
monarch_dodra wrote: void main() { uint[5] arr1; arr1[].fill(rndGen); uint[5] arr2; arr2[].fill(rndGen); writeln("arr1: ", arr1[]); writeln("arr1: ", arr2[]); } // arr1: [3622200385, 2579361262, 3208046123, 1753759120, 133131992] arr2: [3622200385, 2579361262, 3208046

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
Joseph Rushton Wakeling wrote: It's probably worth investigating the algorithms out there for this kind of functionality, because I doubt the algorithm that's given is optimal. Given that the lazy version will hardly be possible without allocating O(n) additional memory anyway, the simple sol

Re: DLL supposed to work as specified at http://dlang.org/dll.html?

2013-02-19 Thread deed
D code DLLs called by D code are heavly broken. Don't expect it to work. Any solid workarounds?

Make struct transparent to std.algorithm.sort

2013-02-19 Thread cal
Is there a way to make this sort of thing work? import std.algorithm; struct S { int[] arr; alias arr this; } void main() { auto s = S([1,2,3]); sort(s); // error: template std.algorithm.sort does not match any function // template declaration. Candidates are...

Re: D-DLLs & Python

2013-02-19 Thread jerro
D doesn't use null termination for it's strings, strings are immutable(char)[]. You can form a D slice from a pointer by going slice = ptr[0..length] where length is the length of the array the pointer represents. You can't just take a c style string and expect writeln to work with it. You ca

Re: DLL supposed to work as specified at http://dlang.org/dll.html?

2013-02-19 Thread Benjamin Thaut
Am 19.02.2013 00:27, schrieb deed: I'm running into several issues, so first, is this supposed to work correctly? I'm looking into D code DLLs called by D code. D code DLLs called by D code are heavly broken. Don't expect it to work.

Re: How to read fastly files ( I/O operation)

2013-02-19 Thread monarch_dodra
On Thursday, 14 February 2013 at 18:31:35 UTC, bioinfornatics wrote: Mr.Bio, what usage cases you'll be interested in, other than those counters? some idea such as letter counting: rename identifier trimming sequence from quality value to cutoff convert to a binary format convert to fasta + s

Re: D-DLLs & Python

2013-02-19 Thread John Colvin
On Tuesday, 19 February 2013 at 16:23:45 UTC, Chris wrote: I have written a DLL that I load into a Python program. Everything works fine (DLL is loaded via ctypes, functions can be called and are executed). Only the string handling is giving me a bit of a headache. The string in D is always com

D-DLLs & Python

2013-02-19 Thread Chris
I have written a DLL that I load into a Python program. Everything works fine (DLL is loaded via ctypes, functions can be called and are executed). Only the string handling is giving me a bit of a headache. The string in D is always complete garbage. I have written Python modules in D (with C w

Re: Recurrence

2013-02-19 Thread n00b
Le 19/02/2013 07:09, monarch_dodra a écrit : On Tuesday, 19 February 2013 at 10:37:31 UTC, n00b wrote: Hello. -- MyType increment(MyType previous) { //snip } auto myRec = std.range.recurrence!increment(initialMyType); - ... doesn't work. What am I doing wrong? The documentation doesn'

Re: goto (outer) case

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 01:59:45 UTC, Nick Sabalausky wrote: Consider these nested switches: --- enum Foo {a, b} enum Bar {bar} auto foo = Foo.a; auto bar = Bar.bar; final switch(foo) { case Foo.a: final switch(bar) { case Bar.bar: XX

Exceptions from WinMain

2013-02-19 Thread Dave Brown
Hi folks, The example of setting up a Win32 program in D is a great starting point, but I have a concern about manually setting up and tearing down the D runtime. If myWinMain throws an exception that isn't caught, then it is caught in WinMain instead. This causes us to miss the call to Ru

Re: What is the use case of RandomCover?

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 12:18:43 UTC, Joseph Rushton Wakeling wrote: On 02/19/2013 12:46 PM, Ivan Kazmenko wrote: I'd like to note that my post is about randomCover, not randomSample. I do see the difference between the purpose of randomSample and randomShuffle. But randomCover's effe

Re: What is the use case of RandomCover?

2013-02-19 Thread Joseph Rushton Wakeling
On 02/19/2013 12:27 PM, monarch_dodra wrote: Last but not least, be warned there is an old-standing bug with anything in phobos that takes a PRNG by value. Basically, the PRNG will be duplicated, and generate the same sequence over and over. Ergo, do NOT pass a specific random generator to things

Re: What is the use case of RandomCover?

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 11:46:54 UTC, Ivan Kazmenko wrote: Hi! Thank you for the reply. Hum... randomShuffle and randomSample actually have nothing to do with each other. I'd like to note that my post is about randomCover, not randomSample. I do see the difference between the pur

Re: What is the use case of RandomCover?

2013-02-19 Thread Joseph Rushton Wakeling
On 02/19/2013 12:46 PM, Ivan Kazmenko wrote: I'd like to note that my post is about randomCover, not randomSample. I do see the difference between the purpose of randomSample and randomShuffle. But randomCover's effect is, at the first glance, just a slower version of randomSample wrapped as a

Re: Recurrence

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 10:37:31 UTC, n00b wrote: Hello. -- MyType increment(MyType previous) { //snip } auto myRec = std.range.recurrence!increment(initialMyType); - ... doesn't work. What am I doing wrong? The documentation doesn't seem to imply the function has to b

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
Hi! Thank you for the reply. Hum... randomShuffle and randomSample actually have nothing to do with each other. I'd like to note that my post is about randomCover, not randomSample. I do see the difference between the purpose of randomSample and randomShuffle. But randomCover's effect i

Re: What is the use case of RandomCover?

2013-02-19 Thread monarch_dodra
On Tuesday, 19 February 2013 at 09:04:12 UTC, Ivan Kazmenko wrote: Surely, because randomShuffle is re-ordering the elements in-place, whereas randomCover is not. Sorry, but that does not answer my question. If "in-place shuffle" versus "function return value" was the only intended differenc

Recurrence

2013-02-19 Thread n00b
Hello. -- MyType increment(MyType previous) { //snip } auto myRec = std.range.recurrence!increment(initialMyType); - ... doesn't work. What am I doing wrong? The documentation doesn't seem to imply the function has to be passed as a string, if that's the issue.

Re: goto (outer) case

2013-02-19 Thread Mike James
I'm feeling the wind from Edsger Dijkstra spinning in his grave... -=mike=- "Nick Sabalausky" wrote in message news:20130218205937.0768@unknown... Consider these nested switches: --- enum Foo {a, b} enum Bar {bar} auto foo = Foo.a; auto bar = Bar.bar; final swit

Re: What is the use case of RandomCover?

2013-02-19 Thread Ivan Kazmenko
Surely, because randomShuffle is re-ordering the elements in-place, whereas randomCover is not. Sorry, but that does not answer my question. If "in-place shuffle" versus "function return value" was the only intended difference, randomCover could as well look like this (simplified to int[] ca