Re: Using "internal" macros of a CL implementation



Pascal Costanza <pc@xxxxxxxxx> 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@xxxxxxxx>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607

.



Relevant Pages

  • Re: [Lit.] Buffer overruns
    ... The code I posted was intended to illustrate the API, ... >to suggest perfect implementations of the API, ... interfaces to the basic string stuff, memory allocation, I/O, printf, ...
    (sci.crypt)
  • Re: Sport 2.031 with image startup/shutdown support
    ... The key thing is that the API in Squeak is as close to the VW one as possible. ... Leandro (the Visual Smalltalk Sport implementor) suggests that we should define the Sport API in terms of SUnit tests. ... It's more a matter of nobody being surprised and keeping the API straight and all the implementations in line. ...
    (comp.lang.smalltalk)
  • Re: Ideas for a small asynch I/O example?
    ... blocking API that is a bug. ... application using only blocking API calls. ... Some of the implementations of these newer specs are really badly done ... common userspace libraries rarely implement nonblocking ...
    (comp.unix.programmer)
  • Re: Exposing internal members of an assembly
    ... the abstract classes and interfaces. ... The problem is that some parts of the API are "internal" in the sense ... the implementations will not be able to access ... So you want the derived classes to have access to the members in the ...
    (microsoft.public.dotnet.languages.csharp)