On Sun, 21 Aug 2005, Tobin Fricke wrote:
> Is there an easy way to find the definition of a given function, other
> than grepping through the .scm files? For instance, if I want to look at
> the implementation of "partial" or "D", is there an easy way to find it?
I should have RTFM. Here's from "beginner.txt":
Documentation
There are important sources of documentation that you should know
about. The Scheme system is extensively documented using the Emacs
info system. To get to the info system, type C-h i.
If at any time in a Scheme-mode buffer you want to know the possible
completions of a symbol, just type C-M-i (or M-<tab>). This will pop
up an Edwin window that shows all symbols known by the system
beginning with your initial segment.
You may also want to know the arguments to a procedure. If the cursor
is after the procedure name in an expression, you can type M-A
(meta-shift-a) and a description of the arguments will appear in the
Edwin command-line minibuffer (at the bottom of your Edwin window).
If you want to see the definition of any procedure (including any
non-primitive system procedure) you may use the pretty printer (the pp
procedure). For example:
(pp fib)
(named-lambda (fib n)
(if (< n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
(pp Lagrangian->Hamiltonian)
(named-lambda (Lagrangian->Hamiltonian-procedure the-Lagrangian)
(lambda (H-state)
(let ((t (time H-state))
(q (coordinate H-state))
(p (momentum H-state)))
(define (L qdot)
(the-Lagrangian (up t q qdot)))
((Legendre-transform-procedure L) p))))
The prinout from pp may not be exactly what you typed in, because the
internal representation of your procedure may be "compiled".
--tobin