From: "Michael J. Barillier" <mbarilli@midsouth.rr.com>
Subject: Multiple implementations of low-level functions
Date: Fri, 31 Oct 2003 19:33:23 -0600 [thread overview]
Message-ID: <873cd87tzw.fsf@shadizar.localdomain> (raw)
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
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
next reply other threads:[~2003-11-01 1:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-01 1:33 Michael J. Barillier [this message]
2003-11-01 4:45 ` Multiple implementations of low-level functions Keith Wright
2003-11-02 13:48 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873cd87tzw.fsf@shadizar.localdomain \
--to=mbarilli@midsouth.rr.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).