Internal Documentation
From Gambit wiki
(→Record system) |
|||
| Line 41: | Line 41: | ||
That is, <code>define-type</code>. Based on SRFI-9, but extensions not documented. This email provides the best explanation [https://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20090226/af2ee44c/attachment-0001.txt] | That is, <code>define-type</code>. Based on SRFI-9, but extensions not documented. This email provides the best explanation [https://webmail.iro.umontreal.ca/pipermail/gambit-list/attachments/20090226/af2ee44c/attachment-0001.txt] | ||
| + | |||
| + | ===Introspection=== | ||
| + | ====Symbol introspection==== | ||
| + | To get list of interned symbols: | ||
| + | |||
| + | (define (symbol-table->list st) | ||
| + | |||
| + | (define (symbol-chain s syms) | ||
| + | (let loop ((s s) (syms syms)) | ||
| + | (if (symbol? s) | ||
| + | (loop (##vector-ref s 2) (cons s syms)) | ||
| + | syms))) | ||
| + | |||
| + | (let loop ((lst (vector->list st)) (syms '())) | ||
| + | (if (pair? lst) | ||
| + | (loop (cdr lst) (symbol-chain (car lst) syms)) | ||
| + | (reverse syms)))) | ||
| + | |||
| + | (define (interned-symbols) | ||
| + | (symbol-table->list (##symbol-table))) | ||
| + | |||
| + | (pp (length (interned-symbols))) | ||
| + | |||
| + | (From Gambit ML 2009-03-22) | ||
== Compiler == | == Compiler == | ||
[[Category: Internals]] | [[Category: Internals]] | ||
Revision as of 19:57, 22 March 2009
People who want to contribute to Gambit development will need to learn something about how the Gambit-C runtime and compiler are organized. While we intend that source code documentation be included in the source itself (currently there is very little documentation), we intend that descriptions of program design or algorithms used in the runtime and compiler could be included here.
Contents |
Namespace handling
See Namespaces.
Runtime Library
Memory Management
General notes on internal object storage and memory consumption is on the Debugging page. Also see Notes on Memory Management.
Thread System
I/O System
Arithmetic implementation
Eval
Continuation manipulation
The manual lists continuation-graft, continuation-capture, and continuation-return but doesn't describe them. The REPL debugger, and possibly other things, use them. See Marc Feeley's paper A Better API for First-Class Continuations.
REPL
The REPL has some fairly interesting functions and variables, especially for hackers.
Variables
##repl-location-relative- Should the REPL give relative or absolute pathnames. Note: When using emacs with gambit, it is useful to set it to #f, especially if you change the current-directory.
Functions
##cmd-x- where x is a REPL command letter (typed after a comma from the REPL). Executes that command as if it was executed inside of the REPL. For instance
##cmd-bdisplays a backtrace.
Record system
That is, define-type. Based on SRFI-9, but extensions not documented. This email provides the best explanation [1]
Introspection
Symbol introspection
To get list of interned symbols:
(define (symbol-table->list st)
(define (symbol-chain s syms)
(let loop ((s s) (syms syms))
(if (symbol? s)
(loop (##vector-ref s 2) (cons s syms))
syms)))
(let loop ((lst (vector->list st)) (syms '()))
(if (pair? lst)
(loop (cdr lst) (symbol-chain (car lst) syms))
(reverse syms))))
(define (interned-symbols)
(symbol-table->list (##symbol-table)))
(pp (length (interned-symbols)))
(From Gambit ML 2009-03-22)