Vibe.D - log requests and responses

2016-11-23 Thread Saurabh Das via Digitalmars-d-learn
Hi, Is there an easy way to log all incoming requests and outgoing responses (and perhaps processing time, wait time, etc) in Vibe.D? Thanks, Saurabh

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 02:52:05 UTC, Tofu Ninja wrote: On Thursday, 24 November 2016 at 02:11:21 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see http://dpldocs.in

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 02:11:21 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see http://dpldocs.info/experimental-docs/std.traits.variadicFunctionStyle.html that

Re: the best language I have ever met(?)

2016-11-23 Thread Dsby via Digitalmars-d-learn
On Friday, 18 November 2016 at 17:54:52 UTC, Igor Shirkalin wrote: The simpler - the better. After reading "D p.l." by A.Alexandrescu two years ago I have found my past dream. It's theory to start with. That book should be read at least two times especially if you have asm/c/c++/python3/math/p

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:51:01 UTC, Tofu Ninja wrote: Even with std.traits, you can't know which arguments are variadic. sure, you can. see http://dpldocs.info/experimental-docs/std.traits.variadicFunctionStyle.html that will return variadic style. and the only argument that can be

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:36:54 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:19:04 UTC, Tofu Ninja wrote: You still can't replicate a function with this. you can, by using std.traits and string mixins. Even with std.traits, you can't know which arguments are variadic. The

Re: A simplification of the RvalueRef idiom

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:35:39 UTC, TheGag96 wrote: The thing that gets me more is "return" as a function attribute. I see it under "MemberFunctionAttribute" in the grammar but I can't find an explanation for its use anywhere... YOU ARE NOT SUPPOSED TO KNOW THIS. DON'T LIVE YOUR PLA

Re: A simplification of the RvalueRef idiom

2016-11-23 Thread TheGag96 via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 13:06:27 UTC, Nordlöw wrote: On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote: mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER ANY MORE { alias T = typeof(this); static assert (is(T == struct)); @nogc @safe ref const(

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:19:04 UTC, Tofu Ninja wrote: You still can't replicate a function with this. you can, by using std.traits and string mixins.

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:15:07 UTC, ketmar wrote: On Thursday, 24 November 2016 at 00:04:51 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int)

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Thursday, 24 November 2016 at 00:04:51 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 23:21:53 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be erased on aliasing. the only way to retain it is to have a tuple

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 23:02:30 UTC, Tofu Ninja wrote: Being able to get an alias to (ref int) seems like a bug. you are unable to alias it, `ref` will be erased on aliasing. the only way to retain it is to have a tuple with it. that trick aliases *function* *argument* *tuple*, not

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:48:17 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:28:57 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:28:57 UTC, Tofu Ninja wrote: On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it is

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:19:28 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it is "type with modifier", like "const int" or "immutable int". Since

Re: spam in bugzilla

2016-11-23 Thread Brad Roberts via Digitalmars-d-learn
I've been marking the accounts as spam and moving the bugs to a specific spam product/category. The last few days have been unusual. If it keeps up, I'll investigate ways of potentially dealing with it better, but I really don't want to add friction to the signup process. It's hard enough to

Re: How to declare function with the same call signature as another?

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:14:25 UTC, Tofu Ninja wrote: What is a (ref int)? A tuple with "ref int" as its only member? Since when is ref int a type? it is "type with modifier", like "const int" or "immutable int".

Re: How to declare function with the same call signature as another?

2016-11-23 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 20 November 2016 at 12:06:15 UTC, Tofu Ninja wrote: On Sunday, 20 November 2016 at 11:52:01 UTC, Tofu Ninja wrote: ... Also does not include function linkage :/ Because of the lack of response, I am going to guess there is no way to do this cleanly. Guess I am going to have to br

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 22:00:58 UTC, Steven Schveighoffer wrote: I can't see why you need to deal with the glue layer at all -- just tell the glue layer that it's a list of strings and not dstrings ;) 'cause that is how s2ir.d is done in dmd. ;-) it actually sorts *objects*, and ob

Re: Switch ignores case (?)

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/16 4:44 PM, ketmar wrote: On Wednesday, 23 November 2016 at 21:40:52 UTC, Steven Schveighoffer wrote: So the better way is to sort based on byte array, and just use memcmp for everything. i am not completely sure that this is really better. sorting and generating tables is done in glu

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:40:52 UTC, Steven Schveighoffer wrote: So the better way is to sort based on byte array, and just use memcmp for everything. i am not completely sure that this is really better. sorting and generating tables is done in glue layer, which can be different fo

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 21:31:08 UTC, Steven Schveighoffer wrote: I think it makes the most sense to remove the memcmp, and do binary search based on actual char values. yeah. there is wmemcmp, which can be used to speed up one of the cases ('cause wchar_t has different size on windo

Re: Switch ignores case (?)

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/16 4:31 PM, Steven Schveighoffer wrote: On 11/23/16 2:30 PM, ketmar wrote: this can be fixed either by using slow char-by-char comparisons in druntime, or by fixing codegen, so it would sort strings as byte arrays. I think it makes the most sense to remove the memcmp, and do binary s

Re: Switch ignores case (?)

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/16 2:30 PM, ketmar wrote: On Wednesday, 23 November 2016 at 19:07:49 UTC, Chris wrote: It has something to do with the smart quote, e.g.: it is wrong binary search in `_d_switch_string()`. strings for switch are lexically sorted, and compiler calls `_d_switch_string()` to select one.

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
quickfix: diff --git a/src/rt/switch_.d b/src/rt/switch_.d index ec124e3..83572fe 100644 --- a/src/rt/switch_.d +++ b/src/rt/switch_.d @@ -27,6 +27,32 @@ private import core.stdc.string; extern (C): +import core.stdc.wchar_ : wchar_t, wmemcmp; + + +static if (wchar_t.sizeof == wchar.sizeof) {

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 20:49:01 UTC, Chris wrote: Actually, I came across a compiler message that gave me something like \x19\x20 which I found odd. This sure needs fixing. After all, it's quite a basic feature. So it's back to the old `if` again (for now). yeah, until this is fixe

How to get the name for a Tid

2016-11-23 Thread Christian Köstlin via Digitalmars-d-learn
std.concurrency contains the register function to associate a name with a Tid. This is stored internally in an associative array namesByTid. I see no accessors for this. Is there a way to get to the associated names of a Tid? Thanks, Christian

Re: Switch ignores case (?)

2016-11-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 19:30:01 UTC, ketmar wrote: On Wednesday, 23 November 2016 at 19:07:49 UTC, Chris wrote: It has something to do with the smart quote, e.g.: it is wrong binary search in `_d_switch_string()`. strings for switch are lexically sorted, and compiler calls `_d_swi

Re: the best language I have ever met(?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 19:15:52 UTC, Jonathan M Davis wrote: It's nice, but it's non-standard. So, it seems to me that using it is just going to lead to problems like you ran into in this thread where you posted an example that wasn't valid D, and it'll make you that much more annoye

Linking g++ compiled object files

2016-11-23 Thread Rubikoid via Digitalmars-d-learn
For example, i have test.cpp: #include void test() { printf("test\n"); } And test.d: import std.stdio; extern (C++) void test(); void main() { test(); readln(); } How i should compile test.cpp using g++ to link it normally?

Re: Switch ignores case (?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 19:07:49 UTC, Chris wrote: It has something to do with the smart quote, e.g.: it is wrong binary search in `_d_switch_string()`. strings for switch are lexically sorted, and compiler calls `_d_switch_string()` to select one. the thing is that comparison in `

Re: Switch ignores case (?)

2016-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 23, 2016 19:07:49 Chris via Digitalmars-d-learn wrote: > (I think I marked it as "P1" (default option), maybe it's "P2", > didn't know what to choose) AFAIK, there are no devs that pay any attention to those. Some attention is paid to regression vs enhancement vs etc. But t

Re: the best language I have ever met(?)

2016-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 23, 2016 18:58:55 ketmar via Digitalmars-d-learn wrote: > On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin > > wrote: > > On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote: > >> On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: > >>> Though I

Re: Switch ignores case (?)

2016-11-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 18:34:28 UTC, Steven Schveighoffer wrote: Please file here: https://issues.dlang.org/enter_bug.cgi I think this has been there forever. Happens in 2.040 too (the earliest dmd I have on my system). -Steve Here it is: https://issues.dlang.org/show_bug.cgi

Re: spam in bugzilla

2016-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 23, 2016 13:31:45 Steven Schveighoffer via Digitalmars-d-learn wrote: > See here: https://issues.dlang.org/show_bug.cgi?id=16737 > > I don't want to close/change anything, because the guy's email is the > reporter, and he'll get any updates. Is there a way to mark something

Re: the best language I have ever met(?)

2016-11-23 Thread ketmar via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin wrote: On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote: On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: Though I would argue that it's better to use '_' instead of '$' to denote deduced fixed size, it seems mor

Re: the best language I have ever met(?)

2016-11-23 Thread Igor Shirkalin via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote: On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote: Though I would argue that it's better to use '_' instead of '$' to denote deduced fixed size, it seems more obvious to me: int[_] array = [ 1, 2, 3 ]; alas, `_` is valid ide

Re: Switch ignores case (?)

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/16 1:03 PM, Chris wrote: On Wednesday, 23 November 2016 at 17:33:04 UTC, Steven Schveighoffer wrote: I tested this locally with different ideas. This definitely looks like a codegen bug. I was able to reduce it to: void main() { switch("'"d) { case "'"d: writeln(

spam in bugzilla

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
See here: https://issues.dlang.org/show_bug.cgi?id=16737 I don't want to close/change anything, because the guy's email is the reporter, and he'll get any updates. Is there a way to mark something as spam so it gets deleted, and so there are no emails sent to the reporter? -Steve

Re: Switch ignores case (?)

2016-11-23 Thread Chris via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 17:33:04 UTC, Steven Schveighoffer wrote: I tested this locally with different ideas. This definitely looks like a codegen bug. I was able to reduce it to: void main() { switch("'"d) { case "'"d: writeln("a"); break; case "’

Re: Switch ignores case (?)

2016-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/16 11:28 AM, Chris wrote: Only one of the two cases is considered. What am I doing wrong? ` import std.array; import std.conv; import std.stdio; void main() { auto tokens = to!(dchar[][])(["D"d, "’"d, "Addario"d, "'"d]); // Or use this below: //~ dstring[] tokens = ["D"d, "’"d, "

Re: Curl namelookup_time

2016-11-23 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 13:59:29 UTC, Adam D. Ruppe wrote: On Wednesday, 23 November 2016 at 08:24:46 UTC, Andre Pany wrote: [...] curl_easy_getinfo expects the C handle, CURL*, but you are passing it the D struct, Curl. [...] Thank you Adam. I will create a bug report and also

Switch ignores case (?)

2016-11-23 Thread Chris via Digitalmars-d-learn
Only one of the two cases is considered. What am I doing wrong? ` import std.array; import std.conv; import std.stdio; void main() { auto tokens = to!(dchar[][])(["D"d, "’"d, "Addario"d, "'"d]); // Or use this below: //~ dstring[] tokens = ["D"d, "’"d, "Addario"d, "'"d]; while (!tokens.e

Re: Is there a way to identfy Windows version?

2016-11-23 Thread Bauss via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 15:48:36 UTC, rumbu wrote: On Tuesday, 22 November 2016 at 11:00:52 UTC, Bauss wrote: [...] Obtaining the true Windows version is tricky starting with Windows 8. Be careful when using GetVersionEx, it's deprecated. VerifyVersionInfo is more reliable, but it

Re: Curl namelookup_time

2016-11-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 November 2016 at 08:24:46 UTC, Andre Pany wrote: Curl curl; curl_easy_getinfo(&curl, CurlInfo.namelookup_time, &d); curl_easy_getinfo expects the C handle, CURL*, but you are passing it the D struct, Curl. I don't understand why this even compiles, it should

Re: Sending Tid in a struct

2016-11-23 Thread Christian Köstlin via Digitalmars-d-learn
On 03/03/2012 18:35, Timon Gehr wrote: > On 03/03/2012 12:09 PM, Nicolas Silva wrote: >> Hi, >> >> I'm trying to send structs using std.concurrency. the struct contains >> a Tid (the id of the sender) so that the receiver can send an answer. >> >> say: >> >> struct Foo >> { >>Tid tid; >>str

Curl namelookup_time

2016-11-23 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to get some cUrl measurements like name lookup time. pragma(lib, "curl"); import std.stdio, std.net.curl, etc.c.curl; void main() { Curl curl; curl.initialize(); curl.set(CurlOption.url, "https://www.google.com";); curl.perform(); doubl

Re: Memory allocation failed. Why?

2016-11-23 Thread MGW via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 15:53:39 UTC, Steven Schveighoffer wrote: On 11/21/16 11:53 AM, ag0aep6g wrote: Thank you very much for explaining such a difficult and slippery situation.