On 2011-10-07 07:24, Steve Teale wrote:
Andrei,
I was thinking the same thing about the C level interface sometime in the middle
of last night. A straight translation of mysqld could be put there almost
immediately. I have to make myself translate the character set stuff, and add
that, but it's probably only a days work.
As for the interface, I was influenced at the intermediate level by my memory of
using C#.
I think that a DB interface for D should be something that provides an
understood
set of facilities rather than an interface in the language sense that provides
certain specific methods. This would allow a decent job to be done on individual
databases strengths, while making it easy for D programmers to move from one to
another. I will write up a summary of my thoughts later today, and post it here.
Briefly, I had thought of variants, but am also attracted to the idea of
'compatible structs'. These would be struct definition that when fed to a
suitable
template function, could be determined to be a match for a stated query - a bit
like isForwardRange ;=). Other templates would be provided to automate the
process
of 'applying' arrays of such structs to/from the database. Similar facilities
could be provided for arrays of arrays of variants.
At an even higher level one could have templates that implemented entire
operations, like updating a batch of records.
D's template facilities make such stuff easy to implement once you have certain
primitives to base them on. I am at that point now. I have bridgehead and can
consider breakout.
Steve
As I replied to another post:
I think it's important to have a solid low level database API which
later an object oriented abstraction can be built upon.
In this low level API I don't think that results from SQL quires should
be converted to structs. I think that's up to the higher, object
oriented, level to do.
--
/Jacob Carlborg