mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
updated readme
This commit is contained in:
parent
05ef231de4
commit
90e935f93c
1 changed files with 38 additions and 9 deletions
47
Readme.md
47
Readme.md
|
|
@ -3,6 +3,8 @@ Lake Scheme
|
|||
|
||||
A quick and dirty scheme written in C, for fun and to use while reading The Little Schemer. Very quick and dirty, a weekend hack gone awry.
|
||||
|
||||
Lake Scheme uses RSR5 as a guideline but does not strictly adhere. Specifically some of the standard naming is confusing so it has been clarified. Other things have been changed just to make life in the repl more palatable.
|
||||
|
||||
Compiling & Running
|
||||
===================
|
||||
|
||||
|
|
@ -12,23 +14,25 @@ Install glib 2.x using your package manager, for me it's either `brew install gl
|
|||
|
||||
$ make && ./lake
|
||||
|
||||
That will drop you at a repl. There are booleans, symbols, integers, strings, lists, dotted lists (pairs), lambdas, special forms, and a few primitive functions.
|
||||
That will drop you at a repl. There are booleans, symbols, integers, strings, lists, dotted lists (pairs), lambdas, a few special forms, and some primitive functions.
|
||||
|
||||
> #t
|
||||
#t
|
||||
> (quote symbol)
|
||||
symbol
|
||||
> '(a list of symbols)
|
||||
(a list of symbols)
|
||||
> 101
|
||||
101
|
||||
> "hello"
|
||||
"hello"
|
||||
> (quote (1 2 3 4))
|
||||
(1 2 3 4)
|
||||
> (quote (1 . 2))
|
||||
> '(1 . 2)
|
||||
(1 . 2)
|
||||
> (lambda () "hello")
|
||||
(lambda () "hello")
|
||||
> (define inc (lambda (x) (+ x 1)))
|
||||
> (inc 41)
|
||||
42
|
||||
|
||||
Hooray! That sure is repl-ish.
|
||||
|
||||
|
|
@ -44,14 +48,38 @@ The special forms present so far are: `quote`, `define`, `set!`, `and`, `or`, an
|
|||
> (list 1 2 3 4)
|
||||
(1 2 3 4)
|
||||
|
||||
Woah, we even managed to define a useful function without using any primitives! There are primitives now though. So few they can be easily named. They are named thusly:
|
||||
Woah, we even managed to define a useful function without using any primitives!
|
||||
|
||||
There are primitives now though. So few they can be easily named. They are named thusly:
|
||||
|
||||
* car, cdr, cons
|
||||
* null?
|
||||
* pair?
|
||||
* is? and equal? (is? is like eq? just renamed for clarity)
|
||||
* not
|
||||
* math operations: add, subtract, multiply, and divide (+ - * /)
|
||||
* numeric equals (=)
|
||||
* car, cdr, cons
|
||||
* numeric comparisons: equals, less than, greater than (= < >)
|
||||
|
||||
Deviating from RSR5 `eq?` is called `is?` in Lake Scheme, which I find much clearer.
|
||||
|
||||
> (define a (list 1 2 3 4))
|
||||
> (define b (list 1 2 3 4))
|
||||
> (is? a b)
|
||||
#f
|
||||
> (equal? a b)
|
||||
#t
|
||||
|
||||
One final thing to note is an experiment I call *naked lists* (or expressions). These are only valid at the top level in the repl and are just lists without parens, like so:
|
||||
|
||||
> define empty? (lambda (x) (or (null? x) (is? x 0) (equal? x "") ))
|
||||
> empty? 4
|
||||
#f
|
||||
> empty? (cdr '(a))
|
||||
#t
|
||||
> empty?
|
||||
(lambda (x) (or (null? x) (is? x 0) (equal? x "") ))
|
||||
|
||||
A naked expression with one value evaluates to the single value it contains so that typing in an atomic expression doesn't produce strange results. Due to this behaviour one caveat is that if you want to invoke a function without arguments you cannot use a naked list. When evaluating code from a file naked lists are not parsed at all.
|
||||
|
||||
Lake still needs:
|
||||
|
||||
|
|
@ -59,6 +87,7 @@ Lake still needs:
|
|||
* display values
|
||||
* compare values
|
||||
* basic control flow (if, cond, when)
|
||||
* eval and apply
|
||||
* native type operations:
|
||||
* symbol
|
||||
* boolean (logic)
|
||||
|
|
@ -67,12 +96,12 @@ Lake still needs:
|
|||
* dotted list (head, tail)
|
||||
* a minimal stdlib
|
||||
|
||||
There's enough here to start reading so I'm going to see where the book takes me.
|
||||
There's enough here to start reading so I'm going to see where the book takes me. Other than that as much of the language as possible should be moved from C-land into Scheme-land, like the repl. The present functionality should require less C than there currently is.
|
||||
|
||||
Contributors
|
||||
============
|
||||
|
||||
None of them want any credit.
|
||||
Just me, and I don't want any credit ;-)
|
||||
|
||||
License
|
||||
=======
|
||||
|
|
|
|||
Loading…
Reference in a new issue