renamed prog to begin and added basics for the manual

This commit is contained in:
Felix Brendel
2019-05-15 01:08:44 +02:00
parent 0fb9fbe1ee
commit 5548192dc9
17 changed files with 475 additions and 54 deletions
+17 -17
View File
@@ -1,20 +1,20 @@
(define-syntax (when condition :rest body)
"Doc String for 'when'"
`(if ,condition ,(pair prog body) nil))
`(if ,condition ,(pair begin body) nil))
(define-syntax (unless condition :rest body)
`(if ,condition nil ,(pair prog body)))
`(if ,condition nil ,(pair begin body)))
;; (define-syntax defun (name arguments :rest body)
;; ;; (type-assert arguments :pair)
;; ;; `(define ,name (lambda ,arguments ,body))
;; ;; TODO(Felix: I think we do not need to wrap the body of the lamba
;; ;; in a prog
;; ;; in a begin
;; ;; see if we have a docstring
;; (if (and (= (type (first body)) :string) (not (= (type (rest body)) :nil)))
;; (list 'define name (list 'lambda arguments (first body) (pair 'prog (rest body))))
;; (list 'define name (list 'lambda arguments (pair 'prog body)))))
;; (list 'define name (list 'lambda arguments (first body) (pair 'begin (rest body))))
;; (list 'define name (list 'lambda arguments (pair 'begin body)))))
;; (define-syntax defspecial (name arguments :rest body)
@@ -23,20 +23,20 @@
;; ;; see if we have a docstring
;; (if (and (= (type (first body)) :string) (not (= (type (rest body)) :nil)))
;; (list 'define name (list 'special-lambda arguments (first body) (pair 'prog (rest body))))
;; (list 'define name (list 'special-lambda arguments (pair 'prog body)))))
;; (list 'define name (list 'special-lambda arguments (first body) (pair 'begin (rest body))))
;; (list 'define name (list 'special-lambda arguments (pair 'begin body)))))
;; (define (fib n))
;; (define-syntax define (name :rest value)
;; (print name)
;; (print (type name))
;; (if (= (type name) :pair)
;; (prog
;; (begin
;; ;; (print `(define ,(first name) ,`(pair lambda (pair (rest name) value))))
;; ;; (print rest)
;; (print "\naa\n")
;; (list 'define (first name) (pair 'lambda (pair (rest name) value))))
;; (prog
;; (begin
;; ;; (print (pair 'define (pair name value)))
;; (print "\nbb\n")
;; (pair 'define (pair name value)))))
@@ -47,12 +47,12 @@
(if (= nil clauses)
nil
(if (= (first (first clauses)) 'else)
(prog
(begin
(if (not (= () (rest clauses)))
(error "There are additional clauses after the else clause!")
(pair 'prog (rest (first clauses)))))
(pair 'begin (rest (first clauses)))))
(list 'if (first (first clauses))
(pair 'prog (rest (first clauses)))
(pair 'begin (rest (first clauses)))
(rec (rest clauses))))))
(rec clauses))
@@ -111,7 +111,7 @@ ithe sequence as arguemens."
"Extends a list with the given element, by putting it in
the (rest) of the last element of the sequence."
(if (pair? seq)
(prog
(begin
(define e (end seq))
(mutate e (pair (first e) elem))
seq)
@@ -161,7 +161,7 @@ with (pair elem nil)."
;; (macro-define @op nil)))
;; (when @op
;; (macro-define (eval @symbol) (eval @from))
;; (eval (pair prog @for-body))
;; (eval (pair begin @for-body))
;; (eval (extend (list for @symbol (@op @from) @to) @for-body))))
(define (range :keys from :defaults-to 0 to)
@@ -177,7 +177,7 @@ by the key 'from' and ends with the number defined in 'to'."
(define head result)
(mutate from (increment from))
(while (< from to)
(prog
(begin
(mutate head (pair (first head) (pair (copy from) nil)))
(define head (rest head))
(mutate from (increment from))))
@@ -233,8 +233,8 @@ separators between the arguments and what should be printed after the
las argument."
(define printf-quoted (special-lambda (:keys @sep @end :rest @args)
(if (nil? @args)
(prog (print (eval @end)) nil)
(prog
(begin (print (eval @end)) nil)
(begin
(print (first @args))
(unless (nil? (rest @args))
(print (eval @sep)))