Re: can clone a thread?

2013-12-11 Thread Gianni Pisetta
D is cross-platform, so to have a wrapper for fork() would mean to get it working on Windows, too. std.process, can must use fork() of course, since it is the way to spawn a child process on Posix systems. fork() doesn't clone a thread, but a whole process. So there is no issue with the GC, as it

Re: Python calling D

2013-12-11 Thread FreeSlave
On Wednesday, 11 December 2013 at 05:30:49 UTC, CJS wrote: I'd like to use cython to wrap a D library. It's possible to do this with a statically compiled C library, but it fails when I try with a statically compiled D library. Any suggestions on how to do this successfully? I'm not Cython

Re: can clone a thread?

2013-12-11 Thread Marco Leise
Am Wed, 11 Dec 2013 09:10:09 +0100 schrieb Gianni Pisetta pisetta.gia...@alice.it: No, i think fork or something similar is the way i prefer to go. I'm working on a simple top-down parser, so i save all the data references in the context of the function and at the end of it i create the

Win Headers

2013-12-11 Thread frustrated2
Are there complete windows headers and if yes where can i find them and will they work for 64bit?

Re: Ranges require GC?

2013-12-11 Thread Marco Leise
Am Wed, 11 Dec 2013 08:20:19 +0100 schrieb Frustrated c1514...@drdrb.com: On Wednesday, 11 December 2013 at 02:37:32 UTC, Jonathan M Davis wrote: On Wednesday, December 11, 2013 03:09:52 Frustrated wrote: But surely memory gets allocated in some way? In Programming in D: For

Re: Swapping nibbles range style

2013-12-11 Thread Marco Leise
Am Wed, 11 Dec 2013 07:19:41 +0100 schrieb Volcz vo...@kth.se: Are there any obvious difference between the three solutions I have received? They all to work the same to me. I hope they all work the same! Depending on your background you just might prefer one style over the other. As an

Re: std.file.dirEntries unsorted

2013-12-11 Thread Marco Leise
Am Wed, 11 Dec 2013 08:00:27 +0100 schrieb Jesse Phillips jesse.k.phillip...@gmail.com: It should only be documented. In my experience processing files don't need a particular order and sorting may not be needed by name. Returning a sorted directory is difficult to define, should

Re: Performance of ranges verses direct

2013-12-11 Thread Marco Leise
Am Wed, 11 Dec 2013 08:29:38 +0100 schrieb Frustrated c1514...@drdrb.com: Has anyone done any work on comparing the performance of ranges vs using direct straightforward code(optimized in the sense of the way ranges work but by hand). e.g., How does filter compare to a simple loop over

Re: Type inference and overloaded functions

2013-12-11 Thread Namespace
On Wednesday, 11 December 2013 at 04:01:11 UTC, Ali Çehreli wrote: On 12/10/2013 04:37 PM, Namespace wrote: int[] arr2 = [7, 8, 9]s; assert(is(typeof(arr2) == int[3])); That looks very confusing. The left-hand side looks like a slice, which I can append elements to but its type is

Re: can clone a thread?

2013-12-11 Thread Gianni Pisetta
On Wednesday, 11 December 2013 at 08:54:18 UTC, Marco Leise wrote: Am Wed, 11 Dec 2013 09:10:09 +0100 schrieb Gianni Pisetta pisetta.gia...@alice.it: No, i think fork or something similar is the way i prefer to go. I'm working on a simple top-down parser, so i save all the data references in

Re: Template resolution and interfaces

2013-12-11 Thread qznc
On Tuesday, 10 December 2013 at 17:50:45 UTC, Torje Digernes wrote: http://pastie.org/8542555 Compositing an class via curry fails when I try to use interfaces. Guessing that this is due to when classes are validated for interface implementation and when templates are instantiated. I

Re: Performance of ranges verses direct

2013-12-11 Thread John Colvin
On Wednesday, 11 December 2013 at 07:29:39 UTC, Frustrated wrote: Has anyone done any work on comparing the performance of ranges vs using direct straightforward code(optimized in the sense of the way ranges work but by hand). e.g., How does filter compare to a simple loop over the

universal databade connector as jdbc

2013-12-11 Thread bioinfornatics
Hi, Little question, I'm looking a jdbc like in D ? Does this exists ? Thanks

Re: universal databade connector as jdbc

2013-12-11 Thread QAston
On Wednesday, 11 December 2013 at 10:49:43 UTC, bioinfornatics wrote: Hi, Little question, I'm looking a jdbc like in D ? Does this exists ? Thanks https://github.com/buggins/ddbc - see readme for more info.

Re: universal databade connector as jdbc

2013-12-11 Thread bioinfornatics
On Wednesday, 11 December 2013 at 11:00:40 UTC, QAston wrote: On Wednesday, 11 December 2013 at 10:49:43 UTC, bioinfornatics wrote: Hi, Little question, I'm looking a jdbc like in D ? Does this exists ? Thanks https://github.com/buggins/ddbc - see readme for more info. Cool thanks, i will

Re: Swapping nibbles range style

2013-12-11 Thread bearophile
Marco Leise: return s.chunks(2).map!( c = [cast(char)c.dropOne.front, cast(char)c.front] ).join; So I would use the second version offered by bearophile: auto result = new char[s.length]; foreach (immutable i, ref c; result) c = s[i + (i 1 ? -1 : 1)]; return result; I can

Re: Python calling D

2013-12-11 Thread Chris
On Wednesday, 11 December 2013 at 05:30:49 UTC, CJS wrote: I'd like to use cython to wrap a D library. It's possible to do this with a statically compiled C library, but it fails when I try with a statically compiled D library. Any suggestions on how to do this successfully? Have you had a

Re: Python calling D

2013-12-11 Thread John Colvin
On Wednesday, 11 December 2013 at 11:41:11 UTC, Chris wrote: On Wednesday, 11 December 2013 at 05:30:49 UTC, CJS wrote: I'd like to use cython to wrap a D library. It's possible to do this with a statically compiled C library, but it fails when I try with a statically compiled D library. Any

Re: Python calling D

2013-12-11 Thread John Colvin
On Wednesday, 11 December 2013 at 05:30:49 UTC, CJS wrote: I'd like to use cython to wrap a D library. It's possible to do this with a statically compiled C library, but it fails when I try with a statically compiled D library. Any suggestions on how to do this successfully? 1) have you

Re: universal databade connector as jdbc

2013-12-11 Thread Ary Borenszweig
On 12/11/13 8:05 AM, bioinfornatics wrote: On Wednesday, 11 December 2013 at 11:00:40 UTC, QAston wrote: On Wednesday, 11 December 2013 at 10:49:43 UTC, bioinfornatics wrote: Hi, Little question, I'm looking a jdbc like in D ? Does this exists ? Thanks https://github.com/buggins/ddbc - see

Re: Type inference and overloaded functions

2013-12-11 Thread Chris Cain
On Wednesday, 11 December 2013 at 09:49:13 UTC, Namespace wrote: On Wednesday, 11 December 2013 at 04:01:11 UTC, Ali Çehreli wrote: On 12/10/2013 04:37 PM, Namespace wrote: int[] arr2 = [7, 8, 9]s; assert(is(typeof(arr2) == int[3])); That looks very confusing. The left-hand side

Re: Performance of ranges verses direct

2013-12-11 Thread Joseph Rushton Wakeling
On 11/12/13 11:10, John Colvin wrote: A lot of the performance loss is down to missed optimisations, in particular inlining. Simple example: foreach(i; iota(0, 10)) { ... } should be as fast as foreach(i; 0 .. 10) { ... } but isn't. I remember Andrei noting that this ought to be

writeln calls postblits constructor four times before print

2013-12-11 Thread FreeSlave
Code: module vector; import std.stdio; import std.traits; struct SVector(size_t dim, T = float) { private: T[dim] _arr; public: alias dim dimension; alias dim size; this(this) { debug(SVector) writeln(postblit constructor); } this(const T[dim]

Re: std.file.dirEntries unsorted

2013-12-11 Thread Timothee Cour
yes, I agree sorting should be explicit as there's no natural order. However sorting after calling dirEntries is not great as typically one wants to sort within a given directory level and it's too late to sort once all the directory levels are flattened. so how about having an extra argument that

Re: Type inference and overloaded functions

2013-12-11 Thread Namespace
On Wednesday, 11 December 2013 at 16:28:39 UTC, Chris Cain wrote: On Wednesday, 11 December 2013 at 09:49:13 UTC, Namespace wrote: On Wednesday, 11 December 2013 at 04:01:11 UTC, Ali Çehreli wrote: On 12/10/2013 04:37 PM, Namespace wrote: int[] arr2 = [7, 8, 9]s;

Re: writeln calls postblits constructor four times before print

2013-12-11 Thread bearophile
FreeSlave: By the way, why does writeln able to print this struct? It has no toString() method and its data is private. How does writeln have access to it? writeln is able to print structs that don't have a toString, this is very handy in most cases. When you don't want it, there's

Re: Template resolution and interfaces

2013-12-11 Thread Torje Digernes
On Wednesday, 11 December 2013 at 10:10:11 UTC, qznc wrote: On Tuesday, 10 December 2013 at 17:50:45 UTC, Torje Digernes wrote: http://pastie.org/8542555 Compositing an class via curry fails when I try to use interfaces. Guessing that this is due to when classes are validated for interface

Re: writeln calls postblits constructor four times before print

2013-12-11 Thread bearophile
In theory this should be caught by writefln constraint before the linker. Probably I can turn this into a small enhancement request. On the other hand if you care about this it's better for you to open the ER. Bye, bearophile

Re: universal databade connector as jdbc

2013-12-11 Thread bioinfornatics
On Wednesday, 11 December 2013 at 15:34:25 UTC, Ary Borenszweig wrote: On 12/11/13 8:05 AM, bioinfornatics wrote: On Wednesday, 11 December 2013 at 11:00:40 UTC, QAston wrote: On Wednesday, 11 December 2013 at 10:49:43 UTC, bioinfornatics wrote: Hi, Little question, I'm looking a jdbc like

Re: Type inference and overloaded functions

2013-12-11 Thread Namespace
On Wednesday, 11 December 2013 at 18:31:20 UTC, Namespace wrote: On Wednesday, 11 December 2013 at 16:28:39 UTC, Chris Cain wrote: On Wednesday, 11 December 2013 at 09:49:13 UTC, Namespace wrote: On Wednesday, 11 December 2013 at 04:01:11 UTC, Ali Çehreli wrote: On 12/10/2013 04:37 PM,

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Namespace: void main() { int[] arr0 = [1, 2, 3]; assert(is(typeof(arr0) == int[])); assert(arr0 == [1, 2, 3]); int[3] arr1 = [4, 5, 6]s; assert(is(typeof(arr1) == int[3])); assert(arr1 == [4, 5, 6]); int[] arr2 = [7, 8, 9]s;

Re: Type inference and overloaded functions

2013-12-11 Thread Namespace
On Wednesday, 11 December 2013 at 19:51:24 UTC, bearophile wrote: Namespace: void main() { int[] arr0 = [1, 2, 3]; assert(is(typeof(arr0) == int[])); assert(arr0 == [1, 2, 3]); int[3] arr1 = [4, 5, 6]s; assert(is(typeof(arr1) == int[3]));

Re: std.file.dirEntries unsorted

2013-12-11 Thread Jesse Phillips
On Wednesday, 11 December 2013 at 18:34:54 UTC, Timothee Cour wrote: yes, I agree sorting should be explicit as there's no natural order. However sorting after calling dirEntries is not great as typically one wants to sort within a given directory level and it's too late to sort once all the

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Namespace: I'm unsure. I'm not that familiar with dmd at all, so maybe some more advanced guy like Kenji should review my code and create an own, better pull. In that code there is both the [$] and the []s syntaxes. So it's better to submit them as two separated pull requests for the D

How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
How to handle nested structs when converting C headers? In the following snippet i'm currently converting, how would you convert the nested typed union and structures? Would you declare them separately then use their types in the Tcl_Obj struct? or is there a nice way in D to nest them like

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 22:45:35 UTC, Gary Willoughby wrote: How to handle nested structs when converting C headers? Nested structs and unions like in your example are supported in D too, same syntax, same effect.

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 22:54:04 UTC, Adam D. Ruppe wrote: Nested structs and unions like in your example are supported in D too, same syntax, same effect. Actually, no, not quite the same syntax, I didn't notice the name at the end of the C one (in D, the anonymous nested structs

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static struct instad of struct. Bye, bearophile

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Namespace: I'm pretty nervous, but here is the first: https://github.com/D-Programming-Language/dmd/pull/2952 Good. Keep in mind that at best it will take a month or more for your patch to be accepted. Also patches that implement basic language features like this pass a stringent process of

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile wrote: Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static struct instad of struct. Bye, bearophile Have you got an example

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:27:57 UTC, Gary Willoughby wrote: On Wednesday, 11 December 2013 at 23:12:39 UTC, bearophile wrote: Adam D. Ruppe: Nested structs and unions like in your example are supported in D too, same syntax, same effect. But don't forget to add to use static

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital letter */ /* snip */ } InternalRep internalRep;; // still need a decl

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Gary Willoughby: Have you got an example because i always get: tcl.d(713): Error: no identifier for declarator twoPtrValue tcl.d(718): Error: no identifier for declarator ptrAndLongRep tcl.d(719): Error: no identifier for declarator internalRep In D you can't define a struct/union and use it

Question about function aliases

2013-12-11 Thread Gary Willoughby
For example i have some C code like this: typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp)); void Tcl_CallWhenDeleted(Tcl_Interp* interp, Tcl_InterpDeleteProc* proc, ClientData clientData); I intend on converted this to D thus: alias void

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Adam D. Ruppe
On Wednesday, 11 December 2013 at 23:36:11 UTC, bearophile wrote: In D you can't define a struct/union and use it to define an instance on the fly. Well, you can if it is anonymous. struct Foo { union { struct { ubyte a; ubyte b; } ubyte[2] arr; } } That works in D,

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread bearophile
Adam D. Ruppe: Well, you can if it is anonymous. struct Foo { union { struct { ubyte a; ubyte b; } ubyte[2] arr; } } That works in D, and it makes foo.a == arr[0] and foo.b == arr[1]; Right :-) I like D structs. Bye, bearophile

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread Gary Willoughby
On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote: On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital letter */ /* snip */ } InternalRep internalRep;; // still need a decl

Re: How to handle nested structs when converting C headers?

2013-12-11 Thread H. S. Teoh
On Thu, Dec 12, 2013 at 12:54:58AM +0100, Gary Willoughby wrote: On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote: On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby wrote: static union internalRep try static union InternalRep { /* note the capital

Re: Question about function aliases

2013-12-11 Thread dnewbie
On Wednesday, 11 December 2013 at 23:42:44 UTC, Gary Willoughby wrote: For example i have some C code like this: typedef void (Tcl_InterpDeleteProc) _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp)); void Tcl_CallWhenDeleted(Tcl_Interp* interp, Tcl_InterpDeleteProc* proc, ClientData

Re: Type inference and overloaded functions

2013-12-11 Thread Namespace
On Wednesday, 11 December 2013 at 23:20:30 UTC, bearophile wrote: Namespace: I'm pretty nervous, but here is the first: https://github.com/D-Programming-Language/dmd/pull/2952 Good. Keep in mind that at best it will take a month or more for your patch to be accepted. Also patches that

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Ali Çehreli: int[] arr2 = [7, 8, 9]s; assert(is(typeof(arr2) == int[3])); That looks very confusing. The left-hand side looks like a slice, which I can append elements to but its type is a static array? No, the type of the literal is of a fixed-side array, but it gets assigned

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Namespace: Your gig: https://github.com/D-Programming-Language/dmd/pull/2952#discussion_r8288045 My enhancement request was for the array[$] syntax. The idea of []s was invented by someone else (Timothee Cour?). I like the practical comments by Hara. If Kenji thinks the []s is not useful

Re: Type inference and overloaded functions

2013-12-11 Thread Timothee Cour
On Wed, Dec 11, 2013 at 5:17 PM, bearophile bearophileh...@lycos.comwrote: Namespace: Your gig: https://github.com/D-Programming-Language/dmd/pull/ 2952#discussion_r8288045 My enhancement request was for the array[$] syntax. The idea of []s was invented by someone else (Timothee Cour?).

Templating with Function Pointers?

2013-12-11 Thread Maxime Chevalier-Boisvert
I'd like to know if it's possible to create a templated function that takes a function pointer as an argument, and uses static ifs to generate different behaviors based on the type signature of the function pointer. More specifically, I want to create code generation functions for my JIT

Re: Type inference and overloaded functions

2013-12-11 Thread bearophile
Timothee Cour: void fun(int[3]) {} void main() { int[3] x = [1, 2, 3]; fun(x); // OK fun([1, 2, 3]); // error fun([1, 2, 3]s); // OK } Sorry, there's no error there. yes, that was the prime motivation for DIP34, It seems Hara has received your message:

Re: Templating with Function Pointers?

2013-12-11 Thread Ali Çehreli
On 12/11/2013 06:43 PM, Maxime Chevalier-Boisvert wrote: Is it possible to template based on a function pointer argument? If so, is it possible to use static ifs to know the return type or the argument types of the function pointer's signature, as well as how many arguments it takes? That

Re: Win Headers

2013-12-11 Thread evilrat
On Wednesday, 11 December 2013 at 09:04:32 UTC, frustrated2 wrote: Are there complete windows headers and if yes where can i find them and will they work for 64bit? there is mostly complete headers[1], however it is not and never be ready for x64. also there is Andrej Mitrovic's fork[2] of

Re: Templating with Function Pointers?

2013-12-11 Thread Maxime Chevalier-Boisvert
Thanks, I think the std.concurrency code demonstrates exactly what I need :) On Thursday, 12 December 2013 at 05:07:11 UTC, Ali Çehreli wrote: On 12/11/2013 06:43 PM, Maxime Chevalier-Boisvert wrote: Is it possible to template based on a function pointer argument? If so, is it possible to

Re: Win Headers

2013-12-11 Thread frustrated2
thanks for your reply. its a shame that the language does not supply ready to use headers. i can live with missing libraries, but not with incomplete or non working bare minimal prerequisites to use it with an os. that is a sad and sorry state! On Thursday, 12 December 2013 at 05:30:29 UTC,