chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] A call to arms


From: Alaric Snell-Pym
Subject: Re: [Chicken-users] A call to arms
Date: Fri, 23 Jan 2009 01:00:15 +0000


On 22 Jan 2009, at 8:27 pm, Peter Bex wrote:

On Thu, Jan 22, 2009 at 03:01:30PM -0500, Andrew Gwozdziewycz wrote:
So, if you have to simulate features of the storage engine to get
compatibility, all you have to do is tell users that there are some
limitations
to it. Give them the information to choose for themselves. But, on
the
other hand, if they end up growing significantly, and decide to
switch
storage engines from ASCII files to Postgres, why should they have
to do
any more than recompile/restart with a different connection
parameter?

Because if you provide the same abstract interface to all the storage
engines, you won't be able to leverage any of them to their fullest
extent.  You'll always end up either abstracting away too many
essential
details, or provide a way around the abstraction, in which case it
isn't
complete anymore.

All of this is why I decided Wings should sit above this - all it
cares about is getters and setters. If you get those getters and
setters from an OR mapping engine, or something that just wraps SQL
queries:

(define-sql-row flight-cost (id cost))

(make-sql-getter *db-connection* flight-costs "SELECT id,cost FROM
flights WHERE cost < [[cost]] AND destination = [[destination]]")
-> #<procedure (? cost destination)>

Call that function on a cost and destination, and get back a list of
flight-cost records (define-sql-row is much like define-record, except
it makes a constructor that works from an SQL result)

(define-sql-row flight-details (id cost destination))

(make-sql-record-source *db-connection* flight-details "flights" ("id"))

...by introspecting into the structure of flight-details, produces a
function that does:

SELECT id,cost,destination FROM flights WHERE id = ?

...and which has a setter that, given an id and a flight-details-
record, does:

UPDATE flights SET id=?,cost=?,destination=? WHERE id = ?

By putting the abstraction layer above the level of "how the structure
of a result is specified", we can get away with doing all sorts of
different things.

ABS

--
Alaric Snell-Pym
Work: http://www.snell-systems.co.uk/
Play: http://www.snell-pym.org.uk/alaric/
Blog: http://www.snell-pym.org.uk/?author=4






reply via email to

[Prev in Thread] Current Thread [Next in Thread]