Socket.select interrupted system call because of GC

2013-08-03 Thread Marek Janukowicz
I have a program with one thread waiting on Socket.select call and another thread doing stuff causing GC to kick in. When this happens, Socket.select fails with Interrupted system call. I found referenced to some old discussion and bug, but it seems to be long gone (I output SA_RESTART in my

Re: Hello D-world!, imports South African D-naughts

2013-08-03 Thread evilrat
On Saturday, 3 August 2013 at 05:24:11 UTC, Andre Artus wrote: On Saturday, 3 August 2013 at 04:38:13 UTC, Andre Artus wrote: Hello D-world! My name is Andre Artus, and I'm a programmer from Johannesburg, South Africa. I'm relatively new to D, but so far quite impressed by it. I have been

Re: Hello D-world!, imports South African D-naughts

2013-08-03 Thread Andre Artus
On Saturday, 3 August 2013 at 06:51:40 UTC, evilrat wrote: On Saturday, 3 August 2013 at 05:24:11 UTC, Andre Artus wrote: On Saturday, 3 August 2013 at 04:38:13 UTC, Andre Artus wrote: Hello D-world! My name is Andre Artus, and I'm a programmer from Johannesburg, South Africa. I'm

Re: Hello D-world!, imports South African D-naughts

2013-08-03 Thread Bosak
On Saturday, 3 August 2013 at 09:02:32 UTC, Andre Artus wrote: On Saturday, 3 August 2013 at 06:51:40 UTC, evilrat wrote: On Saturday, 3 August 2013 at 05:24:11 UTC, Andre Artus wrote: On Saturday, 3 August 2013 at 04:38:13 UTC, Andre Artus wrote: Hello D-world! My name is Andre Artus, and

Re: Hello D-world!, imports South African D-naughts

2013-08-03 Thread Bosak
The D Programming Language is kind of old and out of date for the current version of D. There aren't many books for D so you have not much choice. Attributes can be declared with 3 different syntaxes. For example one could write: //--1-- /*Explicitly state attribute before every declaration*/

Re: Component Programming example

2013-08-03 Thread Andre Artus
On Friday, 2 August 2013 at 17:03:44 UTC, Justin Whear wrote: On Fri, 02 Aug 2013 18:59:12 +0200, Jonathan A Dunlap wrote: The example: http://www.drdobbs.com/architecture-and-design/component-programming-in- d/240008321?pgno=4 import std.stdio; import std.array; import std.algorithm;

Re: Hello D-world!, imports South African D-naughts

2013-08-03 Thread Andre Artus
On Saturday, 3 August 2013 at 09:24:25 UTC, Bosak wrote: The D Programming Language is kind of old and out of date for the current version of D. There aren't many books for D so you have not much choice. Attributes can be declared with 3 different syntaxes. For example one could write: //--1--

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread dennis luehring
Am 03.08.2013 08:38, schrieb Marek Janukowicz: void main () { writefln( sa: %d, SA_RESTART ); (new Thread (serverfunc)).start(); (new Thread (clientfunc)).start(); } i have no idea to your main problem but firing threads without any join on the threads in your main program seems very

Eponymous templates ambiguity

2013-08-03 Thread andrea9940
Hello D world, I have just started using templates and mixins to generate some boilerplate code and I have found a little ambiguity: This code compiles fine: private template genTypes() { string eval() { ... } const(char[]) genTypes = eval(); } mixin(genTypes!()); // Working

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread Marek Janukowicz
dennis luehring wrote: Am 03.08.2013 08:38, schrieb Marek Janukowicz: void main () { writefln( sa: %d, SA_RESTART ); (new Thread (serverfunc)).start(); (new Thread (clientfunc)).start(); } i have no idea to your main problem but firing threads without any join on the threads

Re: Eponymous templates ambiguity

2013-08-03 Thread bearophile
andrea9940: ( complete code at http://pastebin.com/FhmrgmZZ ) Simpler code: import std.stdio; import std.typecons; private immutable extensionTable = [ [WGL_ARB_make_current_read, void function(int, int, int), wglMakeContextCurrentARB, void function(),

Re: Eponymous templates ambiguity

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 11:27:30 UTC, andrea9940 wrote: Hello D world, I have just started using templates and mixins to generate some boilerplate code and I have found a little ambiguity: This code compiles fine: private template genTypes() { string eval() { ... }

Re: Eponymous templates ambiguity

2013-08-03 Thread andrea9940
Thanks to both of you !

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread dennis luehring
Am 03.08.2013 13:35, schrieb Marek Janukowicz: dennis luehring wrote: Am 03.08.2013 08:38, schrieb Marek Janukowicz: void main () { writefln( sa: %d, SA_RESTART ); (new Thread (serverfunc)).start(); (new Thread (clientfunc)).start(); } i have no idea to your main problem but firing

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread David Nadlinger
On Saturday, 3 August 2013 at 13:19:53 UTC, dennis luehring wrote: but you should not reduce your sample down to maybe-incorrect (what it seems for me in this case) - the join wouldn't make your sample to big The example given is correct, as druntime guarantees that non-daemon threads will

Debugging templates!

2013-08-03 Thread JS
There has to be a better way?!?!?!?!

Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
void F1(...) { } void F2(...) { //HOW TO pass F1(..) the args we were called with ? }

Re: Debugging templates!

2013-08-03 Thread JS
On Saturday, 3 August 2013 at 14:04:10 UTC, JS wrote: There has to be a better way?!?!?!?! Of course, I mean string mixin's using template.. and the statement was to ask people how they went about it...

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void f2(Args...)(Args args) { f1(args); } void main() { f2(10, hello, 1.5); } Bye, bearophile

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Ali Çehreli
On 08/03/2013 07:58 AM, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; Would you expect the following two lines behave the same? writeln(args);

Re: Debugging templates!

2013-08-03 Thread Bosak
On Saturday, 3 August 2013 at 14:35:52 UTC, JS wrote: On Saturday, 3 August 2013 at 14:04:10 UTC, JS wrote: There has to be a better way?!?!?!?! Of course, I mean string mixin's using template.. and the statement was to ask people how they went about it... I usually write unittests that

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread Marek Janukowicz
David Nadlinger wrote: but you should not reduce your sample down to maybe-incorrect (what it seems for me in this case) - the join wouldn't make your sample to big The example given is correct, as druntime guarantees that non-daemon threads will run to completion before the program

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote: On 08/03/2013 07:58 AM, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; Would you expect the

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
monarch_dodra: writefln(%s, 10, hello, 1.5); = 10 According to a recent discussion with Andrei, that's (thankfully) going to become a run-time exception: http://d.puremagic.com/issues/show_bug.cgi?id=4927 Bye, bearophile

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void f2(Args...)(Args args) { f1(args); } void main() { f2(10,

Checking compiler versions

2013-08-03 Thread H. S. Teoh
What's the way to determine the version of the compiler being used to compile a program? I'm trying to make code compile with 2.063, that currently only works in git HEAD because of an improvement in Phobos. I'd like to be able to somehow version() the compatibility code out in versions later

Re: Checking compiler versions

2013-08-03 Thread H. S. Teoh
On Sat, Aug 03, 2013 at 11:09:08AM -0700, H. S. Teoh wrote: What's the way to determine the version of the compiler being used to compile a program? I'm trying to make code compile with 2.063, that currently only works in git HEAD because of an improvement in Phobos. I'd like to be able to

Re: Reading a structured binary file?

2013-08-03 Thread Gary Willoughby
On Friday, 2 August 2013 at 22:13:28 UTC, Jonathan M Davis wrote: I'd probably use std.mmfile and std.bitmanip to do it. MmFile will allow you to efficiently operate on the file as a ubyte[] in memory thanks to mmap, and std.bitmanip's peek and read functions make it easy to convert multiple

Re: Reading a structured binary file?

2013-08-03 Thread Gary Willoughby
On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to a ubyte[] so the std.bitmanip functions work with it? I'm currently doing this: auto file = new MmFile(file.dat);

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 16:57:41 UTC, Gabi wrote: On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) { foreach (arg; args) arg.writeln; } void

Re: Reading a structured binary file?

2013-08-03 Thread Jonathan M Davis
On Saturday, August 03, 2013 20:23:55 Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to a ubyte[] so the std.bitmanip functions work with it? I'm

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread Gabi
On Saturday, 3 August 2013 at 18:48:17 UTC, monarch_dodra wrote: On Saturday, 3 August 2013 at 16:57:41 UTC, Gabi wrote: On Saturday, 3 August 2013 at 14:58:49 UTC, bearophile wrote: Gabi: //HOW TO pass F1(..) the args we were called with ? import std.stdio; void f1(Args...)(Args args) {

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread bearophile
monarch_dodra: My guess though, is that it's the same syntax as in C? Use a straight up elispis: void foo(...). Note that you *can't* extract the types from the vararg unless you *guess* them from an alternative source (for example, fmt in the printf function) Also, importing core.vararg

Re: Variadic functions: How to pass another variadic function the variadic args?

2013-08-03 Thread monarch_dodra
On Saturday, 3 August 2013 at 19:12:40 UTC, bearophile wrote: monarch_dodra: My guess though, is that it's the same syntax as in C? Use a straight up elispis: void foo(...). Note that you *can't* extract the types from the vararg unless you *guess* them from an alternative source (for

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread David Nadlinger
On Saturday, 3 August 2013 at 15:59:30 UTC, Marek Janukowicz wrote: It's really nice to have some chat about the correctness of example code snippets, but can anyone help me with the original issue? :) Sorry, apparently I forgot to include the actual content:. ;) Socket.select is an ancient

Re: Reading a structured binary file?

2013-08-03 Thread John Colvin
On Saturday, 3 August 2013 at 18:23:58 UTC, Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to a ubyte[] so the std.bitmanip functions work with it? I'm

Re: Reading a structured binary file?

2013-08-03 Thread Jonathan M Davis
On Saturday, August 03, 2013 23:10:12 John Colvin wrote: On Saturday, 3 August 2013 at 18:23:58 UTC, Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea but once the file has been opened as a MmFile how to i convert this to

Re: Reading a structured binary file?

2013-08-03 Thread monarch_dodra
On Friday, 2 August 2013 at 23:51:27 UTC, H. S. Teoh wrote: On Fri, Aug 02, 2013 at 06:38:20PM -0500, captaindet wrote: [...] FWIW i have to deal with big data files that can be a few GB. for some data analysis software i wrote in C a while back i did some testing with caching and such. turns

Re: Reading a structured binary file?

2013-08-03 Thread H. S. Teoh
On Sat, Aug 03, 2013 at 02:25:23PM -0700, Jonathan M Davis wrote: On Saturday, August 03, 2013 23:10:12 John Colvin wrote: On Saturday, 3 August 2013 at 18:23:58 UTC, Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47 UTC, Gary Willoughby wrote: This sounds a great idea

Re: Reading a structured binary file?

2013-08-03 Thread H. S. Teoh
On Sat, Aug 03, 2013 at 11:29:01PM +0200, monarch_dodra wrote: On Friday, 2 August 2013 at 23:51:27 UTC, H. S. Teoh wrote: On Fri, Aug 02, 2013 at 06:38:20PM -0500, captaindet wrote: [...] FWIW i have to deal with big data files that can be a few GB. for some data analysis software i wrote

Started to work on a Lua wrapper. Please provide feedback guidance

2013-08-03 Thread Gabi
I need a Lua 5.2.2 wrapper, So I started working on one.. I am new to D so probably there is a lot of room for improvements.. Any feedback is welcome.. import std.stdio:writeln, writefln; import std.exception:enforce; import std.conv; import std.string; alias void lua_State; alias long

Re: Reading a structured binary file?

2013-08-03 Thread Jonathan M Davis
On Saturday, August 03, 2013 14:31:16 H. S. Teoh wrote: On Sat, Aug 03, 2013 at 02:25:23PM -0700, Jonathan M Davis wrote: On Saturday, August 03, 2013 23:10:12 John Colvin wrote: On Saturday, 3 August 2013 at 18:23:58 UTC, Gary Willoughby wrote: On Saturday, 3 August 2013 at 18:14:47

Re: Started to work on a Lua wrapper. Please provide feedback guidance

2013-08-03 Thread John Colvin
On Saturday, 3 August 2013 at 22:17:32 UTC, Gabi wrote: I need a Lua 5.2.2 wrapper, So I started working on one.. I am new to D so probably there is a lot of room for improvements.. Any feedback is welcome.. import std.stdio:writeln, writefln; import std.exception:enforce; import std.conv;