Re: Right after allocators: containers or database connectivity?

2015-06-11 Thread Erik Smith via Digitalmars-d
I’m actively working on the low level interface and I’m making good progress. My goal is to have a high quality interface definition with working reference drivers for top tier databases. The current references drivers are ODBC, sqlite, mysql, and Oracle. I think it’s important to

Re: std.(experimental.)logger voting manager wanted

2015-06-14 Thread Erik Smith via Digitalmars-d
I've started exploring the use of std.experimental.logger for my std.database work. Presumably it would get in before std.database. What does finalize reference counting mean? (discussion thread?) Is it about RefCounted? I'm using that extensively. erik

resource structs and default constuction

2015-06-01 Thread Erik Smith via Digitalmars-d
I have a struct that uses RefCounted internally to manage a database environment.It’s basically in the same boat as RefCounted itself in that it requires runtime construction. Two things set it apart: 1) No-arg construction is required 2) The potential prevalence of this type in

Re: resource structs and default constuction

2015-06-01 Thread Erik Smith via Digitalmars-d
If you want to force that a constructor be called rather than using the init value, then you need to make the init value unusable by @disabling this(). Then the caller _has_ to explicitly call a constructor or factory function. Regardless, if you want a constructor that takes no arguments for

Re: resource structs and default constuction

2015-06-01 Thread Erik Smith via Digitalmars-d
It shouldn't. It should just make it so that the struct it's in has a @disabled init value as well - which is annoying in its own right, but it's not as restrictive. Regardless, if you want to guarantee that a struct is constructed rather than having its init value used, you have no choice.

Re: std.database

2015-05-27 Thread Erik Smith via Digitalmars-d
Table a, b, c; con.insert!Table(a); ... if you use CTFE to create the statement string there is no reason to reuse it. it will be string literal, that's even better! Think Big. Think D the other code is Java not D The statement reuse with binding is primarily for performance and is

std.database

2015-05-27 Thread Erik Smith via Digitalmars-d
I'm working on a standards grade interface implementation for database clients in D. It defines a common interface (the implicit kind) and allows for both native and polymorphic drivers. A key feature is a range interface to query results. Here's the project page with the design highlights

Re: std.database

2015-05-27 Thread Erik Smith via Digitalmars-d
On Thursday, 28 May 2015 at 03:40:36 UTC, Robert burner Schadek wrote: I believe you're a aiming to low. If you have a struct you could use traits and ctfe to generate perfect sql statements. This would make it possible to a range of struct Customers. That would be awesome I agree that it

Re: std.database

2015-05-27 Thread Erik Smith via Digitalmars-d
Shouldn't the statement be reusable? Yes it should. I added this use case: auto stmt = con.statement(insert into table values(?,?)); stmt.execute(a,1); stmt.execute(b,2); stmt.execute(c,3); Since one obvious use case would be running the behind a http server - vibe.d - using fibers and

Re: std.database

2015-05-28 Thread Erik Smith via Digitalmars-d
It seems std.database.sql not std.database. You can't build, for example, a mongodb driver over this. Maybe, but mongodb is a proprietary nosql interface rather than a standard one so I'm not sure that it should be in std. erik

Re: std.database

2015-05-28 Thread Erik Smith via Digitalmars-d
Maybe make the database providers interfaces instead of data+dispatch? You're allocating the stuff anyway. Do you mean inheriting from interfaces like this? class MysqlStatement : Statement {...} I need deterministic resource management and I don't think classes provide that. Using structs

Re: no size yet for forward reference error

2016-02-25 Thread Erik Smith via Digitalmars-d
Good to know that it's a bug - Thanks for the help. I've created an issue to track this: https://issues.dlang.org/show_bug.cgi?id=15726

no size yet for forward reference error

2016-02-24 Thread Erik Smith via Digitalmars-d
In the process of converting my working database interface to be template based, I now get the following compiler error: Error: struct std.database.mock.database.Statement!int.Statement.Payload no size yet for forward reference I minimized the code to make it easier reason about. It seems

Re: no size yet for forward reference error

2016-02-24 Thread Erik Smith via Digitalmars-d
Here's a better reduction of the problem. Commenting out either of the lines marked HERE eliminates the error. It's some kind of interaction with templates, RefCounted, and the cross referencing types. erik module database; import std.typecons; unittest { auto con =

Re: no size yet for forward reference error

2016-02-25 Thread Erik Smith via Digitalmars-d
I'm running OSX 10.11.2, DMD v2.070 installed via homebrew with --devel flag. erik

type inference by module

2016-02-27 Thread Erik Smith via Digitalmars-d
I'm having a tough time finding a workaround for not being able to reference adjacent types in a module (https://issues.dlang.org/show_bug.cgi?id=15726). This is how I want to do it, but can't: module x.y.z; struct A(T) { alias B = .B!T; } struct B(T) { alias A = .B!T; alias C =

Re: no size yet for forward reference error

2016-02-26 Thread Erik Smith via Digitalmars-d
The struct->class workaround is unworkable in this case because underlying C database clients are often pretty sensitive to out of order resource cleanup and generate errors or crash as a result. The structs are essential but I will limit the design to avoid the issue for now.

RefCounted status

2016-02-20 Thread Erik Smith via Digitalmars-d
My understanding is that using RefCounted is the recommended approach for implementing value types involving shared resources that require deterministic lifetimes. However, there has historically been a race condition involving RefCounted destruction and GC. Is there a solution for this?

Re: std.database

2016-03-10 Thread Erik Smith via Digitalmars-d
I've made a few updates based on some of the feedback in this thread. - execute() renamed to query() - query with input binds directly from connection - query() returns result for chaining The design is still early stage. I've got a growing list of design options which I'll bring into

Re: FreeTDS bindings

2016-03-30 Thread Erik Smith via Digitalmars-d
On Wednesday, 30 March 2016 at 15:42:05 UTC, Nikitas Leogas wrote: I'm new to D, but considering using it in a new project, which will need to connect to MS SQL Server and Sybase ASE databases. I've successfully used FreeTDS for this purpose in the past, so I was looking for the corresponding

Re: std.database

2016-03-04 Thread Erik Smith via Digitalmars-d
On Friday, 4 March 2016 at 11:57:49 UTC, Kagamin wrote: On Thursday, 3 March 2016 at 18:08:26 UTC, Erik Smith wrote: db.execute("select from t").reader; //row range db.execute("select from t").get!long; //scalar db.execute("select from t"); //non-query More good options (the 3rd one is

Re: std.database

2016-03-04 Thread Erik Smith via Digitalmars-d
On Friday, 4 March 2016 at 16:43:00 UTC, Kagamin wrote: On Friday, 4 March 2016 at 14:44:48 UTC, Erik Smith wrote: Actually I like this and I think it can work. I'm trying to keep a single execute function name for both row/no-row queries. I can still return the range proxy for no-row queries

Re: std.database

2016-03-04 Thread Erik Smith via Digitalmars-d
On Friday, 4 March 2016 at 19:27:47 UTC, Bubbasaur wrote: On Friday, 4 March 2016 at 18:42:45 UTC, Erik Smith wrote: auto db = createDatabase("file:///testdb"); auto rowSet = db.connection().statement("select name,score from score").execute; foreach (r; rowSet)

Re: std.database

2016-03-04 Thread Erik Smith via Digitalmars-d
On Friday, 4 March 2016 at 16:54:33 UTC, Kagamin wrote: On Thursday, 3 March 2016 at 17:46:02 UTC, Erik Smith wrote: BTW in the oracle driver you use that ODBC idiom of passing strings as pointer+length pairs. Why don't you use it in ODBC driver? That will be fixed in the next push. erik

Re: std.database

2016-03-06 Thread Erik Smith via Digitalmars-d
On Sunday, 6 March 2016 at 08:53:05 UTC, Kagamin wrote: On Saturday, 5 March 2016 at 18:00:56 UTC, Erik Smith wrote: I'm definitely going to start working in async capability (or more accurately, non-blocking) into the interface. Huh? Non-blocking operation is not reflected in interface. Only

Re: std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
Hi Stefan, It might be a challenge for CTFE compatibility in the API, but it would be interesting to see how much of it is workable. There does need to be some optional API elements in cases where it's not supported by the underlying database client(array binding for example) and these

Re: std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
1. In my opinion it should not be called std.database, but let's say "std.dbc". This is because it looks like a wrapper over db clients. Moreover one may say it's almost impossible to make a common and effective interface which would work with all databases. e.g. someone on Wikipedia argues

std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
I'm back to actively working on a std.database specification & implementation. It's still unstable, minimally tested, and there is plenty of work to do, but I wanted to share an update on my progress. The main focus of this project is to bring a standard interface for database clients.

Re: std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
I will look at your managed approach to understand it better. One drawback I can think of is that destruction might not occur immediately. This can be an issue for shared libraries when the GC hasn't run when the library call returns to the host application. Maybe it's a C++ bias, but the

Re: std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
Yes agree that the poly Database is broken - it isn't reference counted and I will fix that. Your sample code had me wondering if I am missing something else, but I can't see another issue yet. I think the use of classes would definitely lead to problems with resources being freed out of

Re: std.database

2016-03-02 Thread Erik Smith via Digitalmars-d
Typo fixed - thanks. Incidentally, I'm not 100% content with createDatabase. With the library being template based, the types are no longer as easy to work with directly: auto database = Database!DefaultPolicy(); alias cant be used because it instantiates. The template argument can be

Re: std.database

2016-03-03 Thread Erik Smith via Digitalmars-d
On Thursday, 3 March 2016 at 15:07:43 UTC, Kagamin wrote: Also member names: methods are named after verbs, you use nouns. Method `next` is ambiguous: is the first row the next row? `fetch` or `fetchRow` would be better. Those are actually internal methods not intended for the interface

Re: std.database

2016-03-03 Thread Erik Smith via Digitalmars-d
I suggest you call the package stdx.db - it is not (and may not become) a standard package, so `std` is out of question. If it is supposed to be *proposed* as standard package, then `stdx` is good because that is what some people have used in the past (while others used the ugly

Mallocator

2016-03-03 Thread Erik Smith via Digitalmars-d
Just a question on Mallocator and shared. My code does a lot of non-GC heap allocation (malloc) for buffers, so I reached for Mallocator as a starting point. I propagate an Allocator type generically through my structs, but it is defaulted to Mallocator. After checking with the docs & TDPL,

Re: std.database

2016-03-03 Thread Erik Smith via Digitalmars-d
On Thursday, 3 March 2016 at 17:03:58 UTC, Kagamin wrote: On Thursday, 3 March 2016 at 15:53:28 UTC, Erik Smith wrote: auto r = db.connection().statement("select from t").range(); // nouns db.execute("select from t").range(); `range` is probably ok. Or auto connection =

Re: std.database

2016-03-03 Thread Erik Smith via Digitalmars-d
On Thursday, 3 March 2016 at 16:08:03 UTC, Piotrek wrote: I agree with you we need database manipulation in Phobos. However modules like db, gui, xml or similar are too much work for a one developer. And as you can see from time to time there apears someone with its own vision. That's why,

Re: Mallocator

2016-03-03 Thread Erik Smith via Digitalmars-d
On Thursday, 3 March 2016 at 19:32:40 UTC, Brian Schott wrote: On Thursday, 3 March 2016 at 19:01:52 UTC, Erik Smith wrote: I get the error "allocate is not callable using a non-shared object" and I'm not sure how to resolve it. Are you calling `Mallocator.allocate()` or

Re: Mallocator

2016-03-03 Thread Erik Smith via Digitalmars-d
On Thursday, 3 March 2016 at 20:31:47 UTC, Meta wrote: On Thursday, 3 March 2016 at 20:16:55 UTC, Erik Smith wrote: The later works and qualifying the allocator member variable shared seems to solve the issue. Example: struct A(T) { alias Allocator = T; shared Allocator allocator;

Re: std.database

2016-03-04 Thread Erik Smith via Digitalmars-d
On Friday, 4 March 2016 at 22:44:24 UTC, Sebastiaan Koppe wrote: On Friday, 4 March 2016 at 18:42:45 UTC, Erik Smith wrote: auto db = createDatabase("file:///testdb"); auto rowSet = db.connection().statement("select name,score from score").execute; foreach (r; rowSet)

Re: std.database

2016-03-05 Thread Erik Smith via Digitalmars-d
On Saturday, 5 March 2016 at 13:13:09 UTC, Jacob Carlborg wrote: On 2016-03-05 11:23, Saurabh Das wrote: A little late to the party, nevertheless: Thanks for doing this, it will be super-helpful! My only feature request will be: please make it work with minimal effort with Vibe.D! :)

RefCounted / DMD bug

2016-04-15 Thread Erik Smith via Digitalmars-d
I'm getting a strange assertion/crash involving RefCounted and I've reduced it down to the isolated case (see below). This is with D 2.071 and requires this version to compile. I'm wondering if there is something I wrong in the way I'm using RefCounted. I'm using using it to pass RC value

Re: RefCounted / DMD bug

2016-04-16 Thread Erik Smith via Digitalmars-d
On Saturday, 16 April 2016 at 14:50:07 UTC, ag0aep6g wrote: On 16.04.2016 02:56, Erik Smith wrote: I'm getting a strange assertion/crash involving RefCounted and I've reduced it down to the isolated case (see below). This is with D 2.071 and requires this version to compile. Seems to work

Re: Postgres and other database interfaces

2018-02-23 Thread Erik Smith via Digitalmars-d
On Saturday, 24 February 2018 at 05:45:45 UTC, rikki cattermole wrote: There is plenty of desire to build a generalized SQL interface for Phobos. But somebody needs to do it and it won't be all that much fun to do. Hi Joe and Rikki, This is the goal of my dstddb project and I've picked it

Re: Postgres and other database interfaces

2018-02-24 Thread Erik Smith via Digitalmars-d
On Saturday, 24 February 2018 at 18:56:23 UTC, Denis F wrote: On Saturday, 24 February 2018 at 05:45:45 UTC, rikki cattermole wrote: There is plenty of desire to build a generalized SQL interface for Phobos. But somebody needs to do it and it won't be all that much fun to do. I want to

Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:56:59 UTC, Stefan Koch wrote: On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1:

Re: what is equivalent to template template

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
You're close. An `alias` template parameter can be any symbol, including a template. But you can't pass in a template as a runtime parameter, so having `F f` in your parameters list is wrong (there's nothing to pass anyway; you already have the template, which is F). static void call(alias

what is equivalent to template template

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
C++ has template templates. I'm not sure how to achieve the same effect where (in example below) the template function myVariadic is passed to another function. void myVaridatic(A...)(A a) {} static void call(alias F,A...)(F f,A a) { f(a); } void

Re: constructed variadic call

2016-05-03 Thread Erik Smith via Digitalmars-d-learn
I don't think it's possible to call a vararg function whose number of arguments is only known at runtime, for the same reasons it is impossible in C [1]. Your switch statement is probably the best you can do, other than rewriting the API to not use varargs (which, depending on what the

Re: template auto instantiation when parameters empty

2016-05-05 Thread Erik Smith via Digitalmars-d-learn
On Thursday, 5 May 2016 at 16:12:40 UTC, Steven Schveighoffer wrote: On 5/5/16 12:10 AM, Erik Smith wrote: I want to have a struct template auto instantiate when the template parameters are defaulted or missing. Example: struct Resource(T=int) { static auto create() {return

Re: inferred size for static array initialization

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
I tried to combine the two solutions (Basile with the wrapper, Marco with the struct initializer support) but it didn't work. The struct initializer is not a array literal (seems obvious now). I might go with the 2nd but it's pretty heavy just to get the size. Thanks. struct S { int

constructed variadic call

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case 3: foo(a[1], a[2], a[3]); break; ... }

parameter pack to inputRange

2016-05-05 Thread Erik Smith via Digitalmars-d-learn
Is there an existing way to adapt a parameter pack to an input range? I would like to construct an array with it. Example: void run(A...) (A args) { Array!int a(toInputRange(args)); }

Re: parameter pack to inputRange

2016-05-06 Thread Erik Smith via Digitalmars-d-learn
On Friday, 6 May 2016 at 05:20:50 UTC, Ali Çehreli wrote: On 05/05/2016 10:00 PM, Erik Smith wrote: Is there an existing way to adapt a parameter pack to an input range? I would like to construct an array with it. Example: void run(A...) (A args) { Array!int a(toInputRange(args)); }

template auto instantiation when parameters empty

2016-05-04 Thread Erik Smith via Digitalmars-d-learn
I want to have a struct template auto instantiate when the template parameters are defaulted or missing. Example: struct Resource(T=int) { static auto create() {return Resource(null);} this(string s) {} } auto resource = Resource.create; As a plain struct it works, but not as a

inferred size for static array initialization

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definitions. The code below doesn't work when removing the array size even though the array is

Re: parameter pack to inputRange

2016-05-08 Thread Erik Smith via Digitalmars-d-learn
On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote: On 05/05/2016 11:08 PM, Dicebot wrote: > Unless parameter list is very (very!) long, I'd suggest to simply copy > it into a stack struct. Something like this: > > auto toInputRange (T...) (T args) > { > struct Range > { >

Re: parameter pack to inputRange

2016-05-08 Thread Erik Smith via Digitalmars-d-learn
On Sunday, 8 May 2016 at 22:37:44 UTC, Dicebot wrote: On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote: E front() { final switch (index) { /* static */ foreach (i, arg; Args) { case i: return arg;

Re: parameter pack to inputRange

2016-05-08 Thread Erik Smith via Digitalmars-d-learn
On Sunday, 8 May 2016 at 23:49:40 UTC, Ali Çehreli wrote: On 05/08/2016 04:48 PM, Erik Smith wrote: On Sunday, 8 May 2016 at 22:37:44 UTC, Dicebot wrote: On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote: E front() { final switch (index) { /* static