Latest scheme sources and documentation
Patrick Premont
premont@cs.toronto.edu
Sat, 3 Feb 1996 15:05:31 -0500
>
> > http://www.cs.utoronto.ca/~premont/tunes/sources/
> It seems the same as you sent me lately.
I've just put a more recent version. V0.3
It probably doesn't even load correctly because I've been
translating furiously without loading it from time to time.
But about 40% (see progress.scm for the exact figures) of the sources
are now translated and I'm going faster now that I'm used to it.
> I will try to send you some implementation of the HLL- core ASAP.
Maybe we should make sure the thing works as translated before we inflict
another round of changes to it.
> > Unfortunately the current version (0.2) lacks any documentation.
> > There are only comments in the source files. The next version
> > should be documented.
> Do not lose time on documenting.
> A small "what's where" is enough and most useful.
That's what I've done.
> Suggestions:
Version 0.3 does not yet follow your suggestions. The next version will.
> * move all configuration items (paths, anything installation dependent)
> to a "lllscm.config" (*not* .scm to simplify the .Logrc) file,
> that would be produced by a config script from make
> (much like OTOP's Makefile.config).
> * autoconfiguration from given info would be done in some autoconf.scm
> * separate in tools.scm what is really some Scheme library code
> (like bitwise-* which I put in some support.scm file below)
> from what is project management that should go in a main.scm or such
> file.
> * replace file inclusion in lll.scm by (require 'foo) (but possibly
> for including the *config).
>
>
> ------>8------>8------>8------>8------>8------>8------>8------>8------>8------
> ; --------------------- support Scheme code for Tunes -----------------------
>
> ; --- simple counter ---
> (define (make-counter)
> (let ((n -1))
> (lambda ()
> (set! n (+ n 1))
> n)))
>
> ; --- lists as stacks ---
> (define (push! x y) (set! x (cons y x)))
> (define (pop! x) (set! x (cdr x)))
>
>
> ; --- integral powers ---
> ; after all, this seems redundant with expt...
> ; so unless your scheme's expt does it wrong,
> ; you need it not.
> (define (*pow a x n)
> (letrec ((*pow (lambda (a x n)
> (if (zero? n) a
> (*pow (if (odd? n) (* a x) a)
> (* x x)
> (quotient n 2))))))
> (if (and (positive? n) (integer? n))
> (*pow a x n)
> (error "Only positive integer powers implemented."))))
>
> (define (pow x n) (*pow 1 x n))
>
>
> ; --- bit operations ---
>
>
> ; returns (quotient n 2^i) (right-shift)
> (define (>> n i)
> (quotient n (expt 2 i)))
>
> ; returns (* n 2^i) (left-shift)
> (define (<< n i)
> (* n (expt 2 i)))
>
> (define (bitwise op a b)
> (if (and (zero? a) (zero? b))
> 0
> (+ (modulo (op (modulo a 2) (modulo b 2)) 2)
> (* 2 (bitwise op (quotient a 2) (quotient b 2))))))
>
> (define (bitwise-and a b) (bitwise min a b))
> (define (bitwise-or a b) (bitwise max a b))
> (define (bitwise-xor a b) (bitwise + a b))
>
These bitwise operators have undergone some changes in V0.3.
I'll fuse your changes to mine in V0.4.
> ; ---------------------------------------------------------------------------
> ; Error messages and error handling
> ; ---------------------------------------------------------------------------
>
> (define (assert predicate object . rest)
> (if (predicate object)
> object
> (let ((errmsg (if (pair? rest) (car rest) "Object failed assertion :")))
> (Error errmsg object))))
Patrick