From: Arseny Slobodjuck
Subject: Functionality of C headers / module interfaces
Date: 
Message-ID: <3c6aee4e.11563607@news.vtc.ru>
Hi,

  Which is the usual way to achieve functionality of C header files in
Lisp ? That question have practical roots. As for now I ought to move
through source code to see the function arguments and exact name.
Since source grows it becomes hard. I bet there should be an IDE
functions in mature commercial tools for this, there already is
#'apropos and #'describe in CL and there can exist some more
functions. Such tools of course can not be as general as in static
language, because of dynamic nature of Lisp (I can construct a
function or special variable dynamically). I think it will be not hard
to do what I want (to parse Lisp source for defun's, defmacro's,
defparameter etc and generate a report), but maybe that tool already
exists or I shouldn't do it that way at all ?

Arseny. 

From: Jeff Greif
Subject: Re: Functionality of C headers / module interfaces
Date: 
Message-ID: <ufFa8.53$Se.283085@typhoon1.we.ipsvc.net>
Usually, browsing facilities are provided by your Lisp's development
environment, if it has one.  The reflective capabilities, such as
DESCRIBE and APROPOS allow you to build your own browsers.  For example,
here is a crude way to make header files like those you find in C
projects.

(defvar *header-files-path* (pathname "c:/temp/*.txt"))

(defun make-package-header-file (package-name)
  (with-open-file (s (merge-pathnames package-name *header-files-path*)
     :direction :output)
    (do-external-symbols (x  (find-package package-name) )
   (when (fboundp x)
     (describe (symbol-function x) s)))))

Lots of other possibilities exist.

Jeff
From: Arseny Slobodjuck
Subject: Re: Functionality of C headers / module interfaces
Date: 
Message-ID: <3c6b9bb0.505707@news.vtc.ru>
On Thu, 14 Feb 2002 02:26:34 GMT, "Jeff Greif"
<······@spam-me-not.alumni.princeton.edu> wrote:

>(defvar *header-files-path* (pathname "c:/temp/*.txt"))
>
>(defun make-package-header-file (package-name)
>  (with-open-file (s (merge-pathnames package-name *header-files-path*)
>     :direction :output)
>    (do-external-symbols (x  (find-package package-name) )
>   (when (fboundp x)
>     (describe (symbol-function x) s)))))

You're right, let Lisp system parses the source itself !
From: Thom Goodsell
Subject: Re: Functionality of C headers / module interfaces
Date: 
Message-ID: <7vsn84tagh.fsf@shalott.cra.com>
····@altaNOSPAMvista.net (Arseny Slobodjuck) writes:
> Hi,
> 
>   Which is the usual way to achieve functionality of C header files in
> Lisp ? That question have practical roots. As for now I ought to move
> through source code to see the function arguments and exact name.
> Since source grows it becomes hard. I bet there should be an IDE
> functions in mature commercial tools for this, there already is
> #'apropos and #'describe in CL and there can exist some more
> functions. Such tools of course can not be as general as in static
> language, because of dynamic nature of Lisp (I can construct a
> function or special variable dynamically). I think it will be not hard
> to do what I want (to parse Lisp source for defun's, defmacro's,
> defparameter etc and generate a report), but maybe that tool already
> exists or I shouldn't do it that way at all ?
> 
> Arseny. 

You don't mention which iplementation you're using. This is important,
since your environment will (almost?) always give you the signature
for free. For example, when using CMUCL+Emacs+ILISP I can enter the
name of a function, press <space>, and the arguments appear in the
minibuffer. The older version of ACL on Windows that I've used would
do the same thing--pressing space after a entering a function name
displays the arguments in the status bar.

Thom

-- 
(map 'string #'(lambda (char) (let ((char-code (char-code char)))
(code-char (if (< 64 char-code 123) (+ (mod (+ 13 char-code) 52) 65)
char-code)))) ····@IXG.IUS")
From: Pierre R. Mai
Subject: Re: Functionality of C headers / module interfaces
Date: 
Message-ID: <87aducnsem.fsf@orion.bln.pmsf.de>
····@altaNOSPAMvista.net (Arseny Slobodjuck) writes:

>   Which is the usual way to achieve functionality of C header files in
> Lisp ? That question have practical roots. As for now I ought to move
> through source code to see the function arguments and exact name.
> Since source grows it becomes hard. I bet there should be an IDE
> functions in mature commercial tools for this, there already is
> #'apropos and #'describe in CL and there can exist some more
> functions. Such tools of course can not be as general as in static
> language, because of dynamic nature of Lisp (I can construct a
> function or special variable dynamically). I think it will be not hard

To the contrary, those tools can be much more "general" in Common
Lisp, because it not only is very dynamic, but also has great
introspective abilities.  Where you would consult a header file, a
tags file or generated API documentation (like Javadoc), which can
easily get out-of-date w.r.t. the actual source code, when working
with CL you will usually have a running lisp image with your code
loaded, that you can interrogate in order to get _current_ and
detailed information.

Furthermore, even "unmature, free" tools like Emacs+ILISP will offer
you an IDE for CL, which features:

- symbol-name completion (via M-Tab) and apropos in order to find the
  full, correct spelling of a symbol
- access to the argument list of functions, their doc-strings, and
  their source code with the touch of a key (including automatic
  flashing of argument lists in the minibuffer)
- similar facilities for other symbols
- Lots of helpful editing and evaluation operations
- Access to the HyperSpec

Personally I prefer this kind of access to arglist information
strongly over the "grepping in include files" kind.

However if you really wanted to produce a text file that contains much
the same information, CL will give you the tools that allow you to do
it, as another poster has already pointed out.  You might also want to
look at your implementations documentation, and or ILISP, to find
implementation defined functions that give you the argument list of a
function, and maybe its defined type, so that you can write similar
information as describe gives you, but in a format of your own design.

> to do what I want (to parse Lisp source for defun's, defmacro's,
> defparameter etc and generate a report), but maybe that tool already
> exists or I shouldn't do it that way at all ?

The simplest kind of support that most decent editors will give you is
support for tags files, which are generated by etags/ctags (or any of
a number of variant programs), which parse source files, and output
information on defined names, and the location in the source file in a
tags file.  Your editor can be informed to look inside said tags file,
and will then give you:

- Apropos on tags
- Searching for tags
- Showing the source code corresponding to a tag
- Doing search/replace based on tags information

etc.  Modern tags generators support lots of languages, including
Common Lisp (e.g. the GNU one does).

Regs, Pierre.

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein