Insufficient Documentation?

2013-07-29 Thread Manfred Nowak
http://dlang.org/phobos/std_stdio.html: void write(S...)(S args); Writes its arguments in text format to the file. 1) Feeding arguments in text format into the search-function for the whole site does not give a hint to `toString'. What am I missing? 2) to the file ... which file?

Re: Insufficient Documentation?

2013-07-29 Thread Tobias Pankrath
On Monday, 29 July 2013 at 06:17:10 UTC, Manfred Nowak wrote: http://dlang.org/phobos/std_stdio.html: void write(S...)(S args); Writes its arguments in text format to the file. 1) Feeding arguments in text format into the search-function for the whole site does not give a hint to

Generic string join

2013-07-29 Thread JS
Here is a optimal generic string joiner that maximizes compiler optimization, allows for a variable number of arguments that can be strings or arrays of strings. http://dpaste.dzfl.pl/0a021e1f Drawbacks: 1. Static if explosion 2. Not elegant 3. Only works with RT strings or RT

Re: Generic string join

2013-07-29 Thread JS
On Monday, 29 July 2013 at 09:01:36 UTC, JS wrote: Here is a optimal generic string joiner that maximizes compiler optimization, allows for a variable number of arguments that can be strings or arrays of strings. http://dpaste.dzfl.pl/0a021e1f Drawbacks: 1. Static if explosion 2. Not

Async messages to a thread.

2013-07-29 Thread lindenk
Hello! This is partially a general question as I don't know what this is called or if it exists. Say for example I want to do something like the following - import std.concurrency; void main() { void foo() { try { while(true) {

Re: Async messages to a thread.

2013-07-29 Thread John Colvin
On Monday, 29 July 2013 at 15:28:45 UTC, lindenk wrote: Hello! This is partially a general question as I don't know what this is called or if it exists. Say for example I want to do something like the following - import std.concurrency; void main() { void foo() { try {

Re: Async messages to a thread.

2013-07-29 Thread lindenk
void foo(Tid parent) { bool run = true; while(run) { //do_some_blocking_function(); receiveTimeout(dur!msecs(0), (string s){if(s == STAHP!) run = false;} ); } // clean up send(parent, done); } void main() { auto tid =

untuple a tuple

2013-07-29 Thread JS
if I have something like template t(args...) { pragma(msg, args); } it prints out args in a tuple... e.g., tuple!(...) I do not want it to print out the tuple!(). I can write my own pragma and pass each arg to it (e.g., pragma(msg, arg[0], arg[1], ...)) but this is not very general and

Re: Async messages to a thread.

2013-07-29 Thread lindenk
After a bit more research it looks like everyone else uses - while(checkIfRunning()) { // block with timeout } which leads me to believe this might not be possible or standard. Although, should something along the lines of this be possible? Process p = new Process(); p.doTask(p.func());

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 8:28 AM, lindenk ztaticn...@gmail.com wrote: Ah, no I mean, what if do_some_blocking_function blocks for some indeterminate amount of time. I would like it to exit even when it is currently blocking (as it could be unpredictable when it will stop blocking). Execute the

Re: untuple a tuple

2013-07-29 Thread Meta
On Monday, 29 July 2013 at 16:57:49 UTC, JS wrote: if I have something like template t(args...) { pragma(msg, args); } it prints out args in a tuple... e.g., tuple!(...) I do not want it to print out the tuple!(). I can write my own pragma and pass each arg to it (e.g., pragma(msg,

Re: Async messages to a thread.

2013-07-29 Thread Sean Kelly
On Jul 29, 2013, at 10:07 AM, lindenk ztaticn...@gmail.com wrote: After a bit more research it looks like everyone else uses - while(checkIfRunning()) { // block with timeout } which leads me to believe this might not be possible or standard. Although, should something along the

Re: Async messages to a thread.

2013-07-29 Thread lindenk
On Monday, 29 July 2013 at 17:26:55 UTC, Sean Kelly wrote: On Jul 29, 2013, at 10:07 AM, lindenk ztaticn...@gmail.com wrote: After a bit more research it looks like everyone else uses - while(checkIfRunning()) { // block with timeout } which leads me to believe this might not be possible

Re: Async messages to a thread.

2013-07-29 Thread John Colvin
On Monday, 29 July 2013 at 16:19:03 UTC, lindenk wrote: void foo(Tid parent) { bool run = true; while(run) { //do_some_blocking_function(); receiveTimeout(dur!msecs(0), (string s){if(s == STAHP!) run = false;} ); } // clean up send(parent,

Declare reference to variable ?

2013-07-29 Thread Temtaime
I have a long named variable in a struct. For example let's name that longnamedstruct.longnamedmember I need to use that variable in many places of the code and i cannot create the copy of it. In c++ i can auto v = longnamedstruct.longnamedmember; Now i can use v anywhere. Why i cannot

Re: Declare reference to variable ?

2013-07-29 Thread Namespace
On Monday, 29 July 2013 at 21:13:54 UTC, Temtaime wrote: I have a long named variable in a struct. For example let's name that longnamedstruct.longnamedmember I need to use that variable in many places of the code and i cannot create the copy of it. In c++ i can auto v =

Re: Declare reference to variable ?

2013-07-29 Thread Temtaime
No, i cannot. struct S { uint longnamed; } void main() { S somestruct; alias v = somestruct.longnamed; writeln(v); } Error: need 'this' for 'longnamed' of type 'uint' Is it a bug ?

Re: Declare reference to variable ?

2013-07-29 Thread bearophile
Temtaime: I have a long named variable in a struct. For example let's name that longnamedstruct.longnamedmember I need to use that variable in many places of the code and i cannot create the copy of it. You can shorten the outer name with an alias or remove it with a with() statement.

Get template name

2013-07-29 Thread JS
__FUNCTION__ does not return anything when used in templates. For debugging purposes I sometimes use pragma(msg, template_name); (with template_name being the name of the template assigned an enum) I would like to make this more general such as pragma(msg, mixin(__FUNCTION_NAME__)); e.g.,

use template function without assignment

2013-07-29 Thread JS
I have created a template Pragma that emulates pragma but better, the problem is that I have to assign it to something which is very redundant in my code: enum temp = Pragma!(msg) e.g., template Pragma(alias amsg) { string Pragma(string file = __FILE__) { pragma(msg, amsg);

Re: use template function without assignment

2013-07-29 Thread Meta
On Monday, 29 July 2013 at 23:09:20 UTC, JS wrote: I have created a template Pragma that emulates pragma but better, the problem is that I have to assign it to something which is very redundant in my code: enum temp = Pragma!(msg) e.g., template Pragma(alias amsg) { string Pragma(string

Re: use template function without assignment

2013-07-29 Thread Meta
On Tuesday, 30 July 2013 at 01:06:39 UTC, Meta wrote: Does this code do what you want, or are there other requirements as well? void Pragma(alias amsg)(string file = __FILE__) { pragma(msg, amsg); } Actually, sorry, that's the exact same code, just with some syntactic sugar. To

Re: Declare reference to variable ?

2013-07-29 Thread Maxim Fomin
On Monday, 29 July 2013 at 21:37:30 UTC, bearophile wrote: Temtaime: Why i cannot declare reference in D ? I don't know the reasons. But maybe you can create a little struct with just a pointer inside and an alias this to a member function that returns a ref. Bye, bearophile It doesn't

Re: Get template name

2013-07-29 Thread evilrat
On Monday, 29 July 2013 at 23:02:57 UTC, JS wrote: __FUNCTION__ does not return anything when used in templates. For debugging purposes I sometimes use pragma(msg, template_name); (with template_name being the name of the template assigned an enum) I would like to make this more general

Re: Declare reference to variable ?

2013-07-29 Thread Namespace
On Monday, 29 July 2013 at 21:25:21 UTC, Temtaime wrote: No, i cannot. struct S { uint longnamed; } void main() { S somestruct; alias v = somestruct.longnamed; writeln(v); } Error: need 'this' for 'longnamed' of type 'uint' Is it a bug ? Oh, that is