andydude/droscheme — pull request #1 by andydude (2012-03-21 22:24:13+00:00)
Title: Andrew working

Here is an overview of the changes in these commits:

- Multiline REPL
- implemented this as CountParens() in shell.go, then moved to repl.go/ds.go
- the paren counting seems to work well, but we need more testing
- if there is a true read error, then pressing enter twice fixes it
- I realized nothing was happening to the tools I started in tools/
so I renamed this to cmd/ in go style, and renamed droscheme.go to ds.go
so hopefully we will use cmd/ds/ds for a REPL instead of repl/repl,
now that it has a significantly shorter name.
- moved functionality of repl and rpl to cmd/ds (try cmd/ds/ds -h)
- the functionality of repl/repl is default in ds and the functionality
of rpl/rpl is available as "ds -d" for "dont-eval"

- Error Management
- Primitive syntax/procedures must use panics
- High-level things like Read/Eval use second return

- Types (list.go -- should we rename this?)
- added SValues for multiple returns from scheme procs
- added SSyntax for representing primitive syntax
- removed GetHash() -- we can discuss this if needed
- changed SChar to rune instead of int
- I realized the difference between type assertion and IsType():
a type assertion is closed, it can't be satisfied by another type,
whereas IsType() is open. it will work on anything that returns
the right type code; for SPair we need a type assertion, but for
Numbers we need IsType() because the types are different.
- added newError() functions to help making errors consistent.
the idea is that hopefully, all panics will be errors not strings.

- Builtins (builtin.go)
- added some bytevector methods (ref/set!)
- implemented equal? using x.Equal(y) method
- implemented eqv?/eq? using Equal(x, y) func (might be too slow)
- added fold-right
- fixed integer->char
- added make/ for creating rational numbers
- added make-bytevector
- added make-list (might be too slow)
- added make-polar, make-rectangular for creating complex numbers
- added make-vector
- added not
- added num+, num*, num-, num/, num=, num<, num>, num>=, num<=
- there are several advantages of these functions:
by restricting the domain to 2 arg it simplifies the impl.
- all of these are required to promote their args to the same
type before passing them to x.Add(y) so that the methods can
assume that they are adding two numbers of the same type.
- added positive?, negative?, zero?
- added string->utf8, utf8->string using simple go :)
- added u8-vector->bytevector (nonstandard)
- added bytevector->u8-vector (nonstandard)
- added values for constructing SValues objects
- added some vector methods (ref/set!), vector-length
- added vector->list
- rewrote BuiltinEnv() using go reflection :)

- Numbers (num.go)
- moved Num interface to num.go
- moved NumberTypeCode enumeration to num.go
- moved Add2, Mul2 into DnumZI, DnumZH in builtin.go
- implemented DZI (+) and DZH (*) in terms of fold-right
- implemented DZK (-) and DZM (/) with some logic
- added two complex types: SComplex, SComplexPolar
the idea is that if either real/imag are inexact, then
it gets "promoted" to complex128, so the only thing we
need to handle is exact rational numbers
- started with type conversions, still lots TODO
- added unify() which is used in num+, num*, num=, etc.

- Syntax
- rewrote lexNumber() to accept all number syntax (except R6RS |prec notation)
- added (UN|Q)QUOTE (UN|Q)SYNTAX tokens to lexer and parser
- added characters to lexer, \x still TODO
- added Kdefine, Kif, Kquote, KsetZA instead of switch in shell.go
- added methods to Env (and replaced all Env with *Env)
- added MangleName() and UnmangleName() for builtins
- added tools/mangle/mangle.go util
- rewrote EvalSyntax() to use environment instead of switch (most recent change)