[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple implementations of low-level functions
From: |
Michael J. Barillier |
Subject: |
Multiple implementations of low-level functions |
Date: |
Fri, 31 Oct 2003 19:33:23 -0600 |
User-agent: |
Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.2 (gnu/linux) |
I've been hacking on a system for which I would like to have multiple
implementations of low-level functions, which would be called by
higher-level code. (e.g. A test version with static data, v. a test
version with data stored in a database, v. a production version
running against an Oracle database and communicating with other
processes.)
As I see it, I've got two options, but I'm trolling for others:
(1) Something SICP-like, with a closure that's passed around,
returning a function based on a selector, as in:
(use-module (test-implementation))
(define impl (make-test-implementation args...))
((impl 'get-records) "first key" "second key")
(2) Load functions at the start of program execution, before the
high-level stuff is loaded/called:
(load "test-implementation")
(get-records "first key" "second key")
There also might be a module-based solution, but I haven't ventured
down that route.
I've written apps using the first solution, and it worked fine, other
than some nasty nesting of functions and having to pass a parameter
around. The second option is nice for its simplicity, and from the
viewpoint of building up the Scheme (or Lisp) environment/library of
available functions, loading higher-level stuff onto lower-level code.
Anyone care to weigh in on either method, or propose a sexier
solution?
--
Michael J. Barillier mbarilli(at)midsouth.rr.com /"\ ASCII Ribbon
Reg Linux user #125310 <http://counter.li.org/> \ / Campaign against
A. Because that's not how people read. X HTML and RTF
Q. Why is top-posting email replies bad? / \ email
- Multiple implementations of low-level functions,
Michael J. Barillier <=