On Aug 31, 2009, at 1:36 PM, Eric Day wrote:
Hi everyone!
Ross and I have had a very thorough thread going on about libdrizzle
and some questions have come out of it. Here are a couple decisions
we would like feedback on:
libdrizzle will optionally allocate memory for your objects if you
do not. For example, you can do:
/* User allocated. */
drizzle_st drizzle;
drizzle_create(&drizzle);
or:
/* libdrizzle allocated */
drizzle_st *drizzle;
drizzle= drizzle_create(NULL)
What do folks think about this interface? Would having two functions
be preferable to just one? For example:
drizzle_st drizzle;
drizzle_init(&drizzle)?
and:
drizzle_st *drizzle;
drizzle= drizzle_new(void); /* Calls malloc() and drizzle_init() */
There's not much difference to me as someone who worked on
DBD::drizzle and now is building a proxy using libdrizzle. I do think
it flows a little more nicely to say "give me a new drizzle object" or
"initialize my drizzle object". The current system works fine and
doesn't result in any horribly ugly or hard to follow code. It *is* a
little confusing whether or not I need to check the returned value if
I pass in my own externally allocated object.
Next, should the default behavior of drizzle_query be to wait for
the result header or return immediately and require another function
to read the result header? This is currently a behavior flag so you
choose either one, but we still need a default behavior. For example:
drizzle_query("SELECT ...", result);
/* Start using result. */
or:
drizzle_query("SELECT ...", result);
/* Do something else here since we didn't block on the result
read(). */
drizzle_result_read(result);
/* Start using result. */
The latter case is better for applications that may want to perform
some other work before blocking on the result read().
I'd prefer the query function to just send the query and return. It
makes it very clear what the code is doing.. there's no "magic"
happening because of a flag.
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp