Debugging bad requests with vibe

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface Obsever { @property void observe(Observation ra); } void main() { auto test = Observation("a duck",

Re: String to binary conversation

2018-02-08 Thread Marc via Digitalmars-d-learn
On Monday, 5 February 2018 at 18:40:40 UTC, Steven Schveighoffer wrote: On 2/5/18 1:27 PM, Vino wrote: Hi All, Request your help on how to convert a string to binary,eg "test" to 01110100 01100101 01110011 01110100. import std.stdio, std.string; writefln("%(%b %)", "test".representation);

Debugging on Windows

2018-02-08 Thread JN via Digitalmars-d-learn
Hi, is there any way to debug binaries on Windows? I'd at least like to know which line of code made it crash. If it's D code, I get a call trace usually, but if it's a call to a C library, I get a crash and that's it. I am using VSCode and I'd prefer to debug in it if possible, but using

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 8 February 2018 at 20:16:22 UTC, Marc wrote: What's a di file? (sorry google didn't help with that) A di file is just a D file that, by convention, only has function signatures without bodies.

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 08, 2018 20:16:22 Marc via Digitalmars-d-learn wrote: > What's a di file? (sorry google didn't help with that) I"m not sure where the documentation for it is, but it's the D equivalent of a header file. Basically, it's essentially the same as a .d file except that it's only

Re: free func "front" is not picked up as a candidate when doing range.front(...)

2018-02-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 08, 2018 08:18:20 aliak via Digitalmars-d-learn wrote: > On Thursday, 8 February 2018 at 07:16:43 UTC, Jonathan M Davis > > wrote: > > It would be a disaster if free functions could override member > > functions. For starters, it would be impossible to call the > > member

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Timothee Cour via Digitalmars-d-learn
makes sense to show these (version X11), but that could be done using dmd and a special flag instead of having to rely on a new parser (which would need to be kept updated) On Thu, Feb 8, 2018 at 6:49 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: > On

Re: Debugging bad requests with vibe

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson wrote: I have set up a vibe.d rest interface (on a server) and have a client on my machine. struct Observation { string desc; DateTime time; } interface Obsever { @property void observe(Observation ra); } void main() {

Re: Vibe.d rest & web service?

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 18:47:05 UTC, Steven Schveighoffer wrote: Yes you can, but it's not pretty. interface MyInterface { void postGiveMeData(SomeData d); } class MyInterfaceImpl : MyInterface { void postGiveMeData(SomeData d) { ... } void getPage() { ... } void index()

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Marc via Digitalmars-d-learn
On Thursday, 8 February 2018 at 07:21:05 UTC, Jonathan M Davis wrote: On Wednesday, February 07, 2018 13:39:55 Timothee Cour via Digitalmars-d- learn wrote: [...] It's useful with stuff like version(Ddoc). [...] What's a di file? (sorry google didn't help with that) It's been my

Re: free func "front" is not picked up as a candidate when doing range.front(...)

2018-02-08 Thread aliak via Digitalmars-d-learn
On Thursday, 8 February 2018 at 19:32:42 UTC, Jonathan M Davis wrote: On Thursday, February 08, 2018 08:18:20 aliak via Digitalmars-d-learn wrote: On Thursday, 8 February 2018 at 07:16:43 UTC, Jonathan M Davis wrote: > It would be a disaster if free functions could override > member

Re: free func "front" is not picked up as a candidate when doing range.front(...)

2018-02-08 Thread aliak via Digitalmars-d-learn
On Thursday, 8 February 2018 at 07:16:43 UTC, Jonathan M Davis wrote: It would be a disaster if free functions could override member functions. For starters, it would be impossible to call the member function if that were allowed, whereas you can always call a free function by not using UFCS.

Re: free func "front" is not picked up as a candidate when doing range.front(...)

2018-02-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 08, 2018 21:58:39 aliak via Digitalmars-d-learn wrote: > On Thursday, 8 February 2018 at 19:32:42 UTC, Jonathan M Davis > > wrote: > > On Thursday, February 08, 2018 08:18:20 aliak via > > > > Digitalmars-d-learn wrote: > >> On Thursday, 8 February 2018 at 07:16:43 UTC,

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Timothee Cour via Digitalmars-d-learn
likewise, will scope(exit) add any overhead over naive code in the case where no exception is thrown? ``` void fun(){ ... scope(success) {bar;} ... } vs void fun(){ ... if(foo1){ bar; // add this before each return return; } ... bar; return; } ``` On Thu, Feb 8, 2018

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Timothee Cour via Digitalmars-d-learn
> It's been my understanding that it's always been illegal to provide a definition for a function that was declared previously unless it was declared in a .di file Compiler has always allowed that: ``` void fun(); void fun(){} ``` (but see details in bug report) > It's useful with stuff like

are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Timothee Cour via Digitalmars-d-learn
I'm curious whether scope guards add any cost over the naive way, eg: ``` void fun(){ ... scope(success) {bar;} ... } ``` vs: ``` void fun(){ ... if(foo1){ bar; // add this before each return return; } ... bar; return; } ``` For scope(success) and scope(failure), the

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 February 2018 at 10:09:12 UTC, Timothee Cour wrote: I'm curious whether scope guards add any cost over the naive way, eg: ``` void fun(){ ... scope(success) {bar;} ... } ``` vs: ``` void fun(){ ... if(foo1){ bar; // add this before each return return; }

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Daniel Kozak via Digitalmars-d-learn
I mean scope(success), for scope(exit) there is no speed penalty On Thu, Feb 8, 2018 at 12:03 PM, Daniel Kozak wrote: > Yes, it add, but is almost zero > > On Thu, Feb 8, 2018 at 12:00 PM, Timothee Cour via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: >

Re: Vibe.d rest & web service?

2018-02-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 February 2018 at 10:51:39 UTC, Arjan wrote: On Wednesday, 7 February 2018 at 20:23:10 UTC, Nicholas Wilson wrote: On Wednesday, 7 February 2018 at 19:50:31 UTC, Jacob Carlborg wrote: Have you tried this? No. But apart from the fact that I forgot to make the class inherit from

Re: Vibe.d rest & web service?

2018-02-08 Thread Arjan via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 20:23:10 UTC, Nicholas Wilson wrote: On Wednesday, 7 February 2018 at 19:50:31 UTC, Jacob Carlborg wrote: Have you tried this? No. But apart from the fact that I forgot to make the class inherit from an interface to that the rest interface would actually

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Timothee Cour via Digitalmars-d-learn
I know that, my question is whether it adds any runtime overhead over naive way (which is to call the "bar" finalizer before each return statement) in the case where no exception is thrown On Thu, Feb 8, 2018 at 2:44 AM, Mike Parker via Digitalmars-d-learn

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Seb via Digitalmars-d-learn
On Thursday, 8 February 2018 at 10:44:37 UTC, Mike Parker wrote: On Thursday, 8 February 2018 at 10:09:12 UTC, Timothee Cour wrote: I'm curious whether scope guards add any cost over the naive way, eg: ``` void fun(){ ... scope(success) {bar;} ... } ``` vs: ``` void fun(){ ...

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Seb via Digitalmars-d-learn
On Thursday, 8 February 2018 at 11:23:43 UTC, Daniel Kozak wrote: I mean scope(success), for scope(exit) there is no speed penalty On Thu, Feb 8, 2018 at 12:03 PM, Daniel Kozak wrote: Yes, it add, but is almost zero On Thu, Feb 8, 2018 at 12:00 PM, Timothee Cour via

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 22:39, Timothee Cour wrote: ``` void fun_bad3(T)(T a); // declaration [1] void fun_bad3(T)(T a){}; // definition [2] void test(){ fun_bad3(1); } ``` Error: test_all.fun_bad3 called with argument types (int) matches both: main.d(11): test_all.fun_bad3!int.fun_bad3(int a)

Re: are scope guards (scope(exit, success, failure)) zero-cost abstractions?

2018-02-08 Thread Daniel Kozak via Digitalmars-d-learn
Yes, it add, but is almost zero On Thu, Feb 8, 2018 at 12:00 PM, Timothee Cour via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I know that, my question is whether it adds any runtime overhead over > naive way (which is to call the "bar" finalizer before each return >

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 8 February 2018 at 09:42:08 UTC, Timothee Cour wrote: I guess you mean `version(StdDdoc)` ? On that note, I see things like this, which are not DRY: This is actually one of the reasons why I abandoned dmd for my dpldocs.info fork and used an independent parser. dmd tries to