Re: Verifying the arguments of a function with ref parameters?

2016-07-28 Thread pineapple via Digitalmars-d-learn
On Thursday, 28 July 2016 at 21:49:00 UTC, pineapple wrote: On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "Parameters!dgref.init" does not yield a reference. The real error is not displayed. In a normal context it would be "stuff is not callable with" What would be a better

Re: Verifying the arguments of a function with ref parameters?

2016-07-28 Thread pineapple via Digitalmars-d-learn
On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "Parameters!dgref.init" does not yield a reference. The real error is not displayed. In a normal context it would be "stuff is not callable with" What would be a better way to check whether some callable can be called using a

Re: Verifying the arguments of a function with ref parameters?

2016-07-28 Thread ZombineDev via Digitalmars-d-learn
On Thursday, 28 July 2016 at 21:49:00 UTC, pineapple wrote: On Thursday, 28 July 2016 at 20:28:39 UTC, jdfgjdf wrote: "Parameters!dgref.init" does not yield a reference. The real error is not displayed. In a normal context it would be "stuff is not callable with" What would be a better

Re: Autodecode in the wild and An Awful Hack to std.regex

2016-07-28 Thread John Carter via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:48:58 UTC, Seb wrote: We call them DIP (D Improvement Proposals) and I think it's a lot more productive way to discuss improvements than in the forum. Eh. I hoped that somewhere in that explosion of discussion on the topic the problem had been solved and I had

Re: Verifying the arguments of a function with ref parameters?

2016-07-28 Thread jdfgjdf via Digitalmars-d-learn
On Thursday, 28 July 2016 at 19:19:06 UTC, pineapple wrote: Why doesn't this code do what I'd expect it to, and how can I fix it? unittest{ import std.traits : Parameters; // Works as expected alias dg = int delegate(int value); enum bool dgcallable =

Re: Transform/Compile to C/CPP as a target

2016-07-28 Thread Seb via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? Just FYI there is a project that does the reverse. Calypso creates a bridge between DMD/LDC and Clang, both at the AST level (DMD <=> Clang's AST,

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread drug007 via Digitalmars-d-learn
On 28.07.2016 21:45, Ali Çehreli wrote: On 07/27/2016 04:51 AM, drug wrote: > cfoo.copy(foo); // fails to compile because phobos in case of array uses > // array specialization and this specialization fails > // see >

Verifying the arguments of a function with ref parameters?

2016-07-28 Thread pineapple via Digitalmars-d-learn
Why doesn't this code do what I'd expect it to, and how can I fix it? unittest{ import std.traits : Parameters; // Works as expected alias dg = int delegate(int value); enum bool dgcallable = is(typeof((){dg(Parameters!dg.init);})); pragma(msg,

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread Ali Çehreli via Digitalmars-d-learn
On 07/27/2016 04:51 AM, drug wrote: > cfoo.copy(foo); // fails to compile because phobos in case of array uses > // array specialization and this specialization fails > // see > https://github.com/dlang/phobos/blob/v2.071.1/std/algorithm/mutation.d#L333 Thanks

Re: Transform/Compile to C/CPP as a target

2016-07-28 Thread Sebastien Alaiwan via Digitalmars-d-learn
On Monday, 25 July 2016 at 07:53:17 UTC, Stefan Koch wrote: On Saturday, 23 July 2016 at 12:27:24 UTC, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? The short answer is no, not for any recent version of D. The long answer is it's kind of

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Kagamin via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: Also, I'm assuming what I said about calling destroy(instance) is as correct as calling a cleanup method? Class destructor also automatically calls destructors of struct members of the class.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:24:22 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't

Re: Autodecode in the wild and An Awful Hack to std.regex

2016-07-28 Thread Seb via Digitalmars-d-learn
On Thursday, 28 July 2016 at 09:10:33 UTC, Kagamin wrote: Create an RFE? Given that regex returns results as slices of the input string, using the replacement character doesn't introduce data corruption. We call them DIP (D Improvement Proposals) and I think it's a lot more productive way to

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:02:58 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 15:18:24 UTC, Lodovico Giaretta wrote: 3) at program end, live objects are not scheduled for finalization; 4) at program end, pending finalizations from previous collections may not be run. I didn't know these two, can I get source on them? Also, I'm assuming

Re: Why D isn't the next "big thing" already

2016-07-28 Thread Gorge Jingale via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 10:41:54 UTC, ketmar wrote: On Wednesday, 27 July 2016 at 10:39:52 UTC, NX wrote: Lack of production quality tools like? no, "refactoring" and other crap is not "production quality tools", they are only useful to pretend that you are doing something useful, so

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:24:16 UTC, Suliman wrote: void dbInsert(string login, string uploading_date, string geometry_type, string data) { Statement stmt = conn.createStatement(); //stmt.executeUpdate("..."); // some processing of

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:43:32 UTC, Lodovico Giaretta wrote: No! Never run important finalization in a class destructor! The GC is not obliged to run the destructors, so you may end up with your objects destroyed but the connections still open. For this kind of important things, you

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 14:33:26 UTC, Dechcaudron wrote: On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 2. Should I call destructor and how it's should like? You certainly want to close the connection to the db. Basically, the destructor is intended to free resources such as

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Dechcaudron via Digitalmars-d-learn
I don't know anything about the driver you are using, but from my general experience with DBs I'll try to give you some insight. On Thursday, 28 July 2016 at 14:01:45 UTC, Suliman wrote: 1. Should declaration of them be field of class? I'd say so. If you intend to use each instance of the

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
class GDB { Config config; MySQLDriver driver; DataSource ds; Connection conn; this(Config config) { this.config = config; driver = new MySQLDriver(); string[string] params; string url =

Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
I have for next queston. For example I have class for working with DB (I am using ddbc driver). I put some variables as class fields, and init them in constructor: class GDB { Statement stmt; Config config; MySQLDriver driver; DataSource ds;

Re: Why D isn't the next "big thing" already

2016-07-28 Thread ketmar via Digitalmars-d-learn
On Thursday, 28 July 2016 at 11:41:49 UTC, burjui wrote: Why do you use D then? it is fun. Oh, D is more convenient and robust? no, it is more fun. "Refactoring" is more convenient and robust than sed -i 's/.../.../g'. ues, using specialised tools to do useless work can be counted as

Re: Why D isn't the next "big thing" already

2016-07-28 Thread burjui via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 10:41:54 UTC, ketmar wrote: On Wednesday, 27 July 2016 at 10:39:52 UTC, NX wrote: Lack of production quality tools like? no, "refactoring" and other crap is not "production quality tools", they are only useful to pretend that you are doing something useful, so

Re: Autodecode in the wild and An Awful Hack to std.regex

2016-07-28 Thread Kagamin via Digitalmars-d-learn
A template parameter is usually needed when it affects the output data, but in case of regex it won't do much, because the output data are slices of the input string, so decoding doesn't affect them, only exceptions.

Re: Autodecode in the wild and An Awful Hack to std.regex

2016-07-28 Thread Lodovico Giaretta via Digitalmars-d-learn
On Thursday, 28 July 2016 at 09:10:33 UTC, Kagamin wrote: Create an RFE? Given that regex returns results as slices of the input string, using the replacement character doesn't introduce data corruption. (RFE = Request For Enhancement, right?) Yes, all algorithms that use decode internally

Re: Autodecode in the wild and An Awful Hack to std.regex

2016-07-28 Thread Kagamin via Digitalmars-d-learn
Create an RFE? Given that regex returns results as slices of the input string, using the replacement character doesn't introduce data corruption.

Re: Array of const objects with indirections and std.algorithm.copy

2016-07-28 Thread drug via Digitalmars-d-learn
I see. I'll try to rephrase my question to be clear. We have: ``` struct Foo { int i; float f; } int main() { const(Foo)[] cfoo = [Foo(1, 0.5), Foo(2, 0.75)]; Foo[] foo; cfoo.copy(foo); // it works, constness no matter here because Foo is value type } ``` but