Previous: Within-database, Up: Database Macros [Contents][Index]
Here is an example of within-database
macros:
(require 'within-database) (define my-rdb (add-command-tables (create-database "foo.db" 'alist-table))) (within-database my-rdb (define-command (*initialize* rdb) "Print Welcome" (display "Welcome") (newline) rdb) (define-command (without-documentation rdb) (display "without-documentation called") (newline)) (define-table (processor-family ((family atom)) ((also-ran processor-family))) (m68000 #f) (m68030 m68000) (i386 i8086) (i8086 #f) (powerpc #f)) (define-table (platform ((name symbol)) ((processor processor-family) (os symbol) (compiler symbol))) (aix powerpc aix -) ;; ... (amiga-aztec m68000 amiga aztec) (amiga-sas/c-5.10 m68000 amiga sas/c) (atari-st-gcc m68000 atari gcc) ;; ... (watcom-9.0 i386 ms-dos watcom)) (define-command (get-processor rdb) "Get processor for given platform." (((rdb 'open-table) 'platform #f) 'get 'processor))) (close-database my-rdb) (set! my-rdb (open-command-database! "foo.db")) -| Welcome (my-rdb 'without-documentation) -| without-documentation called ((my-rdb 'get-processor) 'amiga-sas/c-5.10) ⇒ m68000 (close-database my-rdb)