Subject: Re: Using "internal" macros of a CL implementation
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 29 Oct 2006 21:12:55 -0600
Newsgroups: comp.lang.lisp
Message-ID: <1aWdnU36jc8q8NjYnZ2dnUVZ_vSdnZ2d@speakeasy.net>
Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| Victor Kryukov wrote:
| > my question was how one can possibly access such macros
| > (even in non-portable way) to avoid duplicating existing functionality.
...
| In a portable way: Create your own package with a low-level API. Make 
| sure that the API is close to at least one or ore existing low-level 
| APIs. Then you can provide different implementations depending on each 
| implementation, and in some implementations simply make the existing one 
| available through your own package. There exist numerous compatibility 
| layers that do it like this, like ACL-Compat, LW-Compat, 
| trivial-garbage, Closer to MOP, and various others. (For example, CLiki 
| has a page for such compatibility layers.)
+---------------

Victor, here's a classic example of what Pascal's talking about:

    ;;; GETENV -- Mostly-portable code for accessing Unix
    ;;; (or Windows?) environment variables. Morphed very slightly
    ;;; from <URL:http://cl-cookbook.sourceforge.net/os.html>
    ;;; Copyright (c) 2002 The Common Lisp Cookbook Project 
    ;;; See: <URL:http://cl-cookbook.sourceforge.net/license.html>
    (defun getenv (name &optional default)
      (or
       #+CMU (cdr (assoc name ext:*environment-list* :test #'string=))
       #+Allegro (sys:getenv name)
       #+CLISP (ext:getenv name)
       #+ECL (si:getenv name)
       #+SBCL (sb-unix::posix-getenv name)
       #+LISPWORKS (lispworks:environment-variable name)
       default))


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607