[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fyi, a reading of guile source

From: Thien-Thi Nguyen
Subject: Re: fyi, a reading of guile source
Date: Thu, 16 May 2002 21:23:01 -0700

   From: Martin Grabmueller <address@hidden>
   Date: Thu, 16 May 2002 09:49:48 +0200

   For those interested in this: some time ago (when I was trying to
   understand this code myself), I wrote down some notes on the data
   representation in Guile.  I have appended them, but can't guarantee
   whether they are still correct, but I guarantee that they are

thanks for the notes -- very fine!  now in $w/journal/mgrabmue.notes.

see below for preliminary bit-field-diagram.  i'm sure a little string
slinging here and there and it could generate those sweet drawings.

in the end we want to embed such bf-descriptions as comments in the
source, and emacs will generate demos on the fly.  see Project ADHOC for
some front-end work.

(ahh, demos...)


# aside from this initial boilerplate, this is actually -*- scheme -*- code
main='(module-ref (resolve-module '\''(scripts bit-field-diagram)) '\'main')'
exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@"
;;; bit-field-diagram --- Display bit-field diagrams in different ways

;;      Copyright (C) 2002 Free Software Foundation, Inc.
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this software; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
;; Boston, MA 02111-1307 USA

;;; Author: Thien-Thi Nguyen <address@hidden>

;;; Commentary:

;; Usage: bit-field-diagram [ARGS]
;; bit-field-diagram does something.
;; TODO: Write it!

;;; Code:

(define-module (scripts bit-field-diagram)
  :use-module (ice-9 format)
  :export (bit-field-diagram))

(define name  car)
(define width cdr)

(define (bf-description<-string s)      ; alist ((NAME . WIDTH) ...)
  (with-input-from-string s
    (lambda () (read))))

(define (bit-field-diagram . args)
  (let ((bf-description (bf-description<-string (car args))))
    (format #t ",,|~:address@hidden|~},,\n"
            (map (lambda (pair)
                   (list (* 2 (width pair)) (name pair)))

(define (zmain . args)
  (bit-field-diagram "((hello . 15) (there . 37))")

(define main bit-field-diagram)

;;; bit-field-diagram ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]